Example of Invoking a Workflow Process from Script in the Object Manager
Example of Invoking a Workflow Process from Script to Pass Field Values to Process Properties
Unblocking The Main Thread Solving ANRs and Frozen Frames
E script-Examples
1. Example of Invoking a Workflow Process from Script in the Object Manager
This topic gives one example of invoking a workflow process from script in object manager. You might use
this feature differently, depending on your business model.
The following is a sample script that invokes a workflow process called My Account Process. In this example,
the process is invoked in the object manager.
/ Example: Invoking a Workflow Process through scripting
function Invoke_Process()
{
var svc = TheApplication().GetService("Workflow Process Manager");
var Input = TheApplication().NewPropertySet();
var Output = TheApplication().NewPropertySet();
var bo = TheApplication().ActiveBusObject();
var bc = bo.GetBusComp("Account");
var rowId = bc.GetFieldValue("Id");
Input.SetProperty("ProcessName", "My Account Process");
Input.SetProperty("Object Id", rowId);
svc.InvokeMethod("RunProcess", Input, Output);
}
Example of Invoking a Workflow Process from Script to Pass Field Values to
Process Properties
This topic gives one example of invoking a workflow process from script to pass field values to process
properties. You might use this feature differently, depending on your business model.
The following script invokes a workflow process called My Opportunity Process. In this example, the
workflow process is invoked in the object manager. Field values are passed to process properties defined in
the workflow process.
//Example: Passing Field Values to Process Properties
function Invoke_Process()
{
var svc = TheApplication().GetService("Workflow Process Manager");
var Input = TheApplication().NewPropertySet();
var Output = TheApplication().NewPropertySet();
var bo = TheApplication().ActiveBusObject();
var bc = bo.GetBusComp("Opportunity");
var rowId = bc.GetFieldValue("Id");
var accountId = bc.GetFieldValue("Account Id");
Input.SetProperty("ProcessName", "My Opportunity Process");
Input.SetProperty("Object Id", rowId);
// Pass the value of the Account Id field to the Account Id process property
Input.SetProperty("Account Id", accountId);
svc.InvokeMethod("RunProcess", Input, Output);