W020 – Process scripting
What you will learn ?
Add script to business process.
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.