Using the Server Requests Business Service to Start a Workflow Process from a Script
The following example code uses the Server Requests business service to start a Workflow Process from a script, and then passes field values to process properties:
//Example: Passing Field Values to Process Properties and start workflow from script
using the Server Request BS
function Invoke_Process()
{
try {
var svc = TheApplication().GetService("Workflow Process Manager(Server Request)");
var psInput = TheApplication().NewPropertySet();
var psOutput = TheApplication().NewPropertySet();
var bo = TheApplication().ActiveBusObject();
var bc = bo.GetBusComp("Opportunity");
var rowId = bc.GetFieldValue("Id");
var accountId = bc.GetFieldValue("Account Id");
psInput.SetProperty("ProcessName", "My Opportunity Process");
psInput.SetProperty("Object Id", rowId);
// Pass the value of the Account Id field to the Account Id process property
psInput.SetProperty("Account Id", accountId);
svc.InvokeMethod("RunProcess", psInput, psOutput);
}
finally
{
psOutput = null;
psInput = null;
svc = null;
}