Description: Sample Groovy Script to set the Dynamic aDecision Variable based on Form field value, which can be used in the next decision gateway condition. This script should only be used along with the visual Workflow.
NOTE: You can set only a numeric value from 1 to 99 to the dynamic aDecision Variable.
TIP:
This applies only to Radio or Dropdown options on a form.
This method works only with static data.
The text string must reference the Value field, not the Label field.
Context: App
App Type: Select an active app type as required.
Remark: Accessible in Post task mode only.
Script:
def execute(){
/**************** Configurable Parameter Section *******************************************************/
String statusTextField ="RES_View_Reviewer_Status";// field name of form XML <my:DS_MSGSTATUS>COO-Approved</my:DS_MSGSTATUS>
/******************************************************************************************************/
FormVO formVO = formService.getFormDetails(true);
String statusText = formService.getFormFieldValuesFromXML(formVO.getXmlData(), statusTextField);
int aDecisionVaribale = 0;
if((statusText !=null) && (statusText.equalsIgnoreCase("Approved")))
{
aDecisionVaribale = 1;
}
else if((statusText !=null) && (statusText.equalsIgnoreCase("Rejected"))){
aDecisionVaribale = 2;
}
if(aDecisionVaribale > 0){
List<ScriptResponseVO> responseActions =new ArrayList<ScriptResponseVO>();
ScriptResponseVO variableParamVo =new ScriptResponseVO();
variableParamVo.setResponseAction(ResponseActionEnum.UPDATE_WORKFLOW_VARIABLE);
Map<String,Object> variableParamMap =new HashMap<>();
variableParamMap.put(IGroovyConstant.DYNAMIC_ADECISION_VARIABLE, aDecisionVaribale);// You can set any value between 1 to 99 to this "aDecisionVaribale" variable
variableParamVo.setResponseObject(variableParamMap);
responseActions.add(variableParamVo);
return responseActions;
}
}
