W020 – Process scripting

What you will learn ?

Add script to business process.

STEP 1 : Search Business process configuration

Access the business process thru _Business Process /Businessprocess menu

STEP 2 : choose the business process

Choose the business process you want to change the definition

STEP 3 : edit script

Choose the Edit script action to open script editor

STEP 4 : Script

Add script to business process

Exercise :

  • Enter the script below for the AppCreateCustomer process
  • Then clear the cache and test
    AppCreateCustomer.evalScore = function() {  
    console.log("BEGIN evalScore"+this.getParameter("APPCC-CLIENT.Field.row_id"));  
    var clientId = this.getParameter("APPCC-CLIENT.Field.row_id").get(0);  
    console.log("clientId="+clientId);  
    // Create customer interests
    var a = this.getActivity("APPCC-INTEREST");  
    var af = this.getContext(a);  
    var df = af.getDataFile("Field", "row_id", false);  
    if (df) {  
        var interetIds = df.getValues();  
        var o = this.getGrant().getTmpObject("AppClientInteret");  
        o.resetValues();  
        for (var i=0; i<interetIds.length; i++) {  
            var interetId = interetIds[i];  
            o.setRowId(ObjectField.DEFAULT_ROW_ID);  
            o.getField("cintClientFK").setValue(clientId);  
            o.getField("cintInteretFK").setValue(interetId);  
            o.save();  
            console.log("interetId="+interetId);  
        }
    }
    // Lance le calcul du score par action
    var c = this.getGrant().getTmpObject("AppClient");  
    c.resetFilters();  
    if (c.select(clientId)) {  
        console.log("invoke action AppClient-Score");  
        var r = c.invokeAction("AppClient-Score");
        console.log("resultat="+r);
    }
    console.log("END evalScore");
    return "OK";
    };

W010 – Create a business workflow

How to create a wizard (set of screens) to assist the user.

W030 – Add an activity link action

Add a activity link action to a business process