How to call a process flow from a Smart Office script

Here is a solution to trigger ProcessFlow Integrator (PFI) from a Personalized Script for Lawson Smart Office (LSO) using the native PF adapter. This technique is new as of LSO 9.1.3.

First, enable the PF configuration in the Smart Office Profile Editor:

Then, use Lawson.Shared.PF.Trigger to determine if Trigger Services are available:

if (PFTrigger.HasTriggerService) {
    // Trigger Services are available
} else {
    // Trigger Services are not available
}

PFTrigger is part of Lawson.Shared.dll:

Then, prepare the trigger:

var service = 'MyService';
var product = 'ERP';
var dataArea = 'PFTST';
var category = '';
var title = 'Test from a script';
var trigger = new PFTrigger(service, product, dataArea, category, title);
trigger.AddVariable('var1''Hello1''String');
trigger.AddVariable('var2''Hello2''String');
trigger.AddVariable('var3''Hello3''String');

Then, execute the trigger:

trigger.SubmitRequest(dataArea, OnTriggerCompleted);

Then, add an event handler:

function OnTriggerCompleted(args: PFTriggerEventArgs) {
    if (args != null && args.IsSuccessful) {
        args.Response.DetailMessage
        args.Response.ErrorCode
        args.Response.InformationCode
        args.Response.ReturnCode
        args.Response.ReturnData
        args.Response.Status
        args.Response.WorkunitNumber
    }
}

Here’s a screenshot of the result:

We can see the HTTP Request and Response with Fiddler:

For versions of Smart Office prior to 9.1.3, it’s possible to trigger PF flows using the old technique with URL. For that, you can use the PFI trigger generator.

The advantage of the new technique is the lower number of lines of code, increased readability, no need to hard-code the hostname, port, user, and password anymore, and no need to handle authentication nor logout.

 

That’s it!

Published by

thibaudatwork

M3 Technical Consultant

17 thoughts on “How to call a process flow from a Smart Office script”

    1. Hi Ahmed, it’s hard to tell what your error is about. HTTP 500 means the server has a problem, likely your PFI server needs to be restarted. Check the PFI server logs in WebSphere. Also, use Fiddler web debugging proxy to capture the trigger sent by Smart Office to PFI, and check the HTTP Response, probably not much since it’s a server problem. Hope it helps. /Tibo

      Like

  1. Hi,

    Can you help me with my error? I’m getting “LHC Exception Encountered” during my process flow trigger. Where can I start checking logs or something?

    P.S. process flow was not executed.

    Like

    1. Hi Doms, I remember having encountered that exception a couple of times, once with a login failure to populate the Inbasket, and somewhere else, but I do not remember any details. I would need to know the context of what you are doing, see the full error message, and screenshots. Otherwise, increase the log level of your process, re-trigger it to get more logs, and check the WorkUnit logs in IPA admin; you have to have the administrator role and have the Rich Client or web admin URL, e.g. http://host:81/lmdevipa/LpaAdmin/; ask your technical consultants for your environment. Otherwise ask on LawsonGuru as there are lots of IPA people there. Hope it helps. –Thibaud

      Like

      1. Oh, that’s why. I actually have that error upon logging in and a ticket was already raised. I asked for help hoping that the two errors are not connected. Thanks for clarifying this Thibaud.

        Liked by 1 person

        1. Hi Thibaud,

          Sorry to bother you again. So just to update on the error from last time the problem was because the client has 2nd network adapters on their servers for backups, these have temporarily been disabled while looking for a resolution for the grid to work with them activated.

          The error has changed now. The error now says “Unable to submit trigger”. I can email you my jscript and a screenshot of my PFI configuration in my profile editor. Would that be fine with you?

          Like

          1. Set the log level to DEBUG/TRACE on the client that triggers the process flow and on the IPA server, and intercept the request/response with Fiddler or Wireshark. The more data you have the easier to troubleshoot.

            Like

            1. Hi Thibaud,

              As it turns out I needed to add the process flow in service definition if I want to trigger it in m3. Otherwise it can only be triggered directly in rich client.

              Liked by 1 person

    1. Ahmed, check this link about how to Dispatch workunit:
      Infor Landmark Technology Administration Guides > Infor Process Automation Administration Guide > Users, Tasks, Filters > Inbasket interface options and display customizations > Infor Process Automation servlets for Inbasket functions
      https://docs.infor.com/help_lmrk_cloudsuite_11.0/topic/com.lawson.help.administration/com.lawson.help.lpaag-c_11.0.x/L2170639708333.html?cp=2_3_0_2_6#d22e4236

      Like

  2. Hi Thibaud,

    Is encrypting supported in jscript? We have a requirement wherein the username & password is being sent to the IPA database via PFTrigger. However, this field should be encrypted with a generic encryption. Generic enough to the point that the M3 transaction node in IPA can support it(still working on the list).

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s