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!