How to use the resultCode property in the Script Unit

From Wiki

Jump to: navigation, search

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.

1: if(condition){
2:   return ["resultCode":"success"] //OKLink followed
3: }else{
4:   return ["resultCode":"error"] //KOLink followed
5: }

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. Image:ScriptUnitValidation.png

Here, the code of the Script Unit is:

1:  //inputs=data
2:  //outputs=message|data
3:  def errors = false
4:  /*
5:  evaluating conditions over data
6:  */
7:  if(errors){
8:    return ["resultCode":"error","message":"there is an error", "data":data] //KOLink followed
9:  }
10: return ["resultCode":"success","message":"data is correct", "data":data] //OKLink followed  
Personal tools