Thursday, Oct. 19, 2017

Invoke a Workflow from a Browser Script

Written By:

|

July 5, 2012

|

Posted In:

Requirement:  To invoke a Workflow from a Browser Script. The workflow would return back a response to the browser script. Based on the response received from the workflow, user may or may not receive a notification/alert on the UI.

There are 2 steps involved to achieve this requirement:

Step 1:  First step is to construct the workflow:

Your workflow can include any validation/operation you want to perform on the business layer. I would like to focus on the tricky part, whether or not to return a notification or not.

Example: A condition check to see if record exists in database based on which a notification/alert may or may not be shown on the UI. If the condition check in the workflow decision branch step “Record Exists” fails, workflow will end and no notification/alert will be displayed to the user on the UI.

However, if record is found then workflow will execute the “Set Property” step, whose configuration would invoke a alert on the UI.

http://www.siebelnova.com


Configure this step “Set Property” as follows:

First step is to create a custom process property say “WFAlert” of type String. Then click on this “Set property” step and mark it as a Business service step with following data:

Business Service Name: Workflow Utilities

Business Service Method: Echo

I/P Arguments:

Blank

O/P Arguments:

Property Name                         Type                            Value

WFAlert                                    Literal                             Y

Step 2: Second step is to call this workflow from browser script and collect the response from this custom workflow.

Write the below lines of code to call this workflow:

if(“<Check your condition to invoke the WF>”)

{      var sId = this.BusComp().GetFieldValue(“Id”);                      //Get the Row Id for the record which triggeres the WF

var inputs = TheApplication().NewPropertySet();                  //Declare an input property set

var outputs = TheApplication().NewPropertySet();                //Declare an output property set

var sWFcomp = TheApplication().GetService(“Workflow Process Manager”);           //Call the vanilla service

inputs.SetProperty(“ProcessName”,”<Your WF Process Name>”);               //Form an input property set

inputs.SetProperty(“Object Id”, sId);                                                                        //Set the Object id here with row id of your record

outputs = sWFcomp.InvokeMethod(“RunProcess”,inputs);                            //Invoke the Workflow

var WFAlert = outputs.GetProperty(“WFAlert”);                                            //Collect the value returned from the Workflow

if(WFAlert == “Y”)

alert(“<paste your Alert message here>”);                                     //Show your notification to the UI if condition is satisfied

   }

Happy Learning !!



Share This Article

About Author

Gurdeep

Hi, I am sharing my experience to alleviate beginners with open UI and HI version of Siebel CRM. I work in Sun Life Financials and can be reached via IT Tool box as well. Thanks.

  • Ranjith R

    Nice. To invoke any Business Service from browser script, it will have to be added to Application’s ClientSideBusinessService list.  Also, i think all the 
    TheApplication in the script should be  theApplication