Open topic with navigation

TIBCO Business Studio™ - BPM Edition 5.4.0

# Sample Scripts

This section contains samples of work manager scripting and process manager scripting.

## Example of Work Manager Scripting:

The JavaScript below is defined on the 'Schedule' Script, meaning that when the work item is scheduled, this script executes. The script is using the WorkManagerFactory.getWorkitem().getWorkItemOffers() method to return the list of resources to which the work item is offered.

WorkManagerFactory methods are defined in Process Manager and Work Manager Scripting.

    var theOfferSet = bpm.workManager.getWorkItem().getWorkItemOffers();
    var i = 0;
    data.DFOfferSet.length(0);
    while (i<theOfferSet.length()){
    //loop through resources in offer set
          var resourcesFromOfferSet = theOfferSet.get(i).getName();
          data.DFOfferSet.push(resourcesFromOfferSet);
    //add resource to OfferSet array field
          i++;
    }

Where 'DFOfferSet' is a data field defined in the process and added as an interface to the user task.

The `WorkManagerFactory.getOrganizationModel` method can be used to navigate around the organization model to identify a particular organizational entity, or are source mapped to such an entity. For example:

    var useResource =
    bpm.workManager.getOrganizationModel().getAssociatedResources(data.EasyAs.ClaimsDept.Manager)

Resources can be located using RQL queries, using the `bpm.workManager.getOrganizationModel().getResourcesByQuery` method.

## Examples of Process Manager Scripting:

The JavaScript below is defined on the 'Initiate' Script meaning that when this user activity is initiated, this script is executed. The script is using the Process.getActivityLoopIndex() method to return the loop index for a multiple instance user task.

    var myActivityLoopIndex = bpm.process.getActivityLoopIndex();
    if (myActivityLoopIndex != null)
    {
          data.UTActivityLoopIndex = myActivityLoopIndex;
    }

Where 'UTActivityLoopIndex' is a data field defined in the process and added as an interface to the user task.

The following example shows extracts from a Process Manager script being used to get information about the organization model:

    var orgModel = bpm.process.getOrgModel();
    var unit1 = orgModel.ouByGuid("_xI4ikMpPEd64gM7QE8RwxA");
    var position1 = orgModel.positionByName("clerk");

Did you find this helpful?

Yes No
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO Business Studio™ - BPM Edition

Copyright © 2015-2023. Cloud Software Group, Inc. All Rights Reserved.