How to use the resultCode property in the Script Unit

From WebRatio WebML 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.

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

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  


Related articles:
Category Difficulty Refers
Context Parameters Web Model Beginner Get Unit
Set Unit
Reset Unit
Create Unit Web Model Beginner Create Unit
Create a "Hello world" application Web Model Beginner Site View
WebML
WebRatio
Create a "Simple data centric" web application Web Model Beginner Site View
WebML
WebRatio
Custom Locations and Master pages Web Model Beginner Master Page
Custom Location
… further results












Did you find this article useful? Please rate it!

Rating: 0.0/5 (0 votes cast)

Personal tools