Skip to main content

Groovy Script- Set Dynamic aDecision Variable based on Form field value

Updated over a week ago

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 1 to 99 value 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

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;

}

}


Did this answer your question?