Process Flow trigger in a batch file

 11 Replies
 1 Subscribed to this topic
 52 Subscribed to this forum
Sort:
Author
Messages
M Graham
Veteran Member
Posts: 32
Veteran Member
    Has anyone created a Process Flow trigger in a batch program, such as PA102 (Position Update) ?  I need a work unit created when a PA102 job is submitted and when "Update"=Y. 
    David Williams
    Veteran Member
    Posts: 1127
    Veteran Member
      Design Studio solution:
      I recently revised a PO190 Close PO form by removing the default action from the Submit button and adding a script to trigger ProcessFlow (via WFWK) to run the job and then run a query of which PO's closed that day for an interface to an external system.
      You could do something like: when the Submit button is clicked, use an AGS call to Submit the job and if Update=Y also trigger ProcessFlow.
      David Williams
      M Graham
      Veteran Member
      Posts: 32
      Veteran Member
        Thanks for the tip David! I did some more research and found a post in the "Design Studio" forum with sample javascript code that I'm looking for, that creates a Process Flow workunit when a batch job has been submitted:
        https://www.lawsonguru.co...v/topic/Default.aspx
        --Marcy

        --------Here is the Design Studio javascript code -------------------

        function FORM_OnBeforeTransaction(fc)
        {
        var vCompany=lawForm.getDataValueById("text4")
        var vUpdate=lawForm.getDataValueById("select3")

        if (vCompany == "1234" || vCompany == "0987" && vUpdate == "Y")
        {
        if (fc == "S")
        {
        var s = portalWnd.AGSPath+"?_PDL=TEST"+
        "&_TKN=WFWK.1&_EVT=ADD&_RTN=DATA&_LFN=ALL&_TDS=IGNORE"+
        "&FC=Add&SERVICE=test100&WORK-TITLE=test100email"+
        "&_DELIM=%09&_OUT=TEXT&_EOT=TRUE";

        portalWnd.httpRequest(s);
        }
        }
        return true;
        }
        David Williams
        Veteran Member
        Posts: 1127
        Veteran Member
          No problem. I took the route I did because I wanted ProcessFlow to actually run the job and for the flow to wait until the job completed in Lawson before moving forward. I added &WAIT=TRUE to the end of the parameters of my WebCall jobrun.exe command to make this happen.
          David Williams
          M Graham
          Veteran Member
          Posts: 32
          Veteran Member
            Good idea to wait until the batch job has completed before moving forward - I'll give that a try.
            -------------------------
            On a related topic...Even though I got a Process Flow workunit to be created when a PA102 batch job is submitted in "Update" mode, no workunit variables are created. Is there a way to create workunit variables in Design Studio? Do I get values from the form and create an AGS command in Design Studio to store the values in the WFVARIABLE table?
            --Marcy
            David Williams
            Veteran Member
            Posts: 1127
            Veteran Member
              // Trigger ProcessFlow
              var s = portalWnd.AGSPath + "?_PDL=" + vProd +
              "&_TKN=WFWK.1&_EVT=ADD&_RTN=DATA&_LFN=ALL&_TDS=IGNORE"+
              "&FC=Add&SERVICE=Batch Notify" +
              "&WORK-TITLE=Batch Notification" +
              "&VARIABLE-NAMEr0=Batch" +
              "&VARIABLE-VALUEr0=" + bBatch +
              "&VARIABLE-NAMEr1=Company" +
              "&VARIABLE-VALUEr1=" + bCompany +
              "&VARIABLE-NAMEr2=Operator" +
              "&VARIABLE-VALUEr2=" + pOperator +
              "&_DELIM=%09&_OUT=TEXT&_EOT=TRUE"
              // submit ags call to server
              var sAGSInfo=portalWnd.httpRequest(s)
              David Williams
              John Cunningham
              Advanced Member
              Posts: 31
              Advanced Member
                Is there a limit on the number of variables that you can send to the ags call. I am trying to send 13 and it seems like it will only get 10.
                Marc Burnes
                Basic Member
                Posts: 14
                Basic Member
                  John,

                  Are you using an older version of ProcessFlow? I am not aware of a limit on the number of arguments that can be passed.

                  Can you post your AGS call?
                  Gary Davies
                  Veteran Member
                  Posts: 248
                  Veteran Member
                    The limit for WFWK is 15. If you want to do more you have to use the COBOL api in the 4GL rather than Design Studio, which allows you to create an unlimited number of variables (10 at a time, calling the api)
                    John Henley
                    Posts: 3353
                      There is actually an "impedance mismatch" between the screen definition and the logic in WFWK. The screen allows for 15 variables, but the logic in the COBOL code only passes 10 variables. Go figure. Depending on what you're doing (you mentioned ags, so are you using PF or DS?), you can also call /bpm/xml/workUnitVariablesForm.do to add the variables individually once the workunit is created. It's a lot more work, but might be your only workaround. Again, depending on what you're doing, another option might be to string together some of the variables to stay within the limit of 10.
                      Thanks for using the LawsonGuru.com forums!
                      John
                      Gary Davies
                      Veteran Member
                      Posts: 248
                      Veteran Member
                        Thanks John, forgot about that little "glitch"

                        You can patch WFWKPD to add an additional call to 1000-ADD-VAR-SETUP if there are values in 11 thru 15.

                        The only problem with using the bpm form is that depending on how the flow is designed, there is no guarentee that the variables will be added in time for when they are to be used because they are created after the workunit has already been triggered. Also if for some reason the call to the bpm form failes they never get added. Slim but still possible.

                        I am not a big fan of using WFWK, because you have to expose the form in security to users so in theory they can trigger any flow if they have any knowledge of AGS. I rather create the trigger in the COBOL (in user exits for online forms) when I can.
                        John Cunningham
                        Advanced Member
                        Posts: 31
                        Advanced Member
                          Thanks Gary.. I was able to concatenate some of the variables in order to get it to work this time. I will probably try cobol triggers next time, there is just a lot of overhead in trying to create a lawson screen for every design studio/processflow you want to create. Might be worth it to design a generic form.