How to use the resultCode property in the Script Unit
From WebRatio WebML Wiki
|
It is possible to use the Script Unit as a source of a KO Link.
In the script it is possible to choose to follow either the OK Link or the KO Link.
This is done by assigning specific values ("success" for the OK Link, "error" for the KO Link) to the implicit map key "resultCode" in the returned map.
if(condition){
return ["resultCode":"success"] //OKLink followed
}else{
return ["resultCode":"error"] //KOLink followed
}
Script Unit validation
As an example, it is possible to perform complex validations, returning specific values in case of error, or saving data in case of success.
Here, the code of the Script Unit is:
#input String data
#output String message, String data
def errors = false
/*
evaluating conditions over data
*/
if(errors){
return ["resultCode":"error","message":"there is an error", "data":data] //KOLink followed
}
return ["resultCode":"success","message":"data is correct", "data":data] //OKLink followed
