Skip to main content
All CollectionsSystem TasksWorking with Groovy ScriptsGroovy Script Library
Groovy Script - Set Due Date of specific timer of Workflow by fetching date from Document's Custom Attribute
Groovy Script - Set Due Date of specific timer of Workflow by fetching date from Document's Custom Attribute
Updated yesterday

Description: Sample groovy script to set due date of specific timer of workflow by fetching date from document's custom attribute

Context: Document

Remark: Accessible in 'Post' task mode only

Script:

def execute()

{

HashMap<Object, Object> optionMap = new HashMap();

optionMap.put(RevisionDetailsOption.BASIC_DETAILS, true);

optionMap.put(RevisionDetailsOption.CUSTOM_ATTRIBUTES, true);

DocumentVO document = documentService.getDocumentDetails(optionMap);

String docExpiryDate = (documentService.getCustomAttributeValue(document, "Expiry_Date")).get(0);

// convert custom attribute date to timer date format

SimpleDateFormat fromDateDormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); // Custom attribute date format-

SimpleDateFormat timerDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // workflow timer date format

String timerDueDate = docExpiryDate +" 23:59:59";

timerDueDate = timerDateFormat.format(fromDateDormat.parse(timerDueDate));

String workflowTimerName = "dueDate_Timer"; // timer name which is defined in workflow

List<ScriptResponseVO> responseActions = new ArrayList<ScriptResponseVO>();

ScriptResponseVO timerParamVo = new ScriptResponseVO();

timerParamVo.setResponseAction(ResponseActionEnum.UPDATE_WORKFLOW_TIMER_DUEDATE);

Map<String, Object> timerParamMap = new HashMap<>();

timerParamMap.put(workflowTimerName, timerDueDate);

timerParamVo.setResponseObject(timerParamMap);

responseActions.add(timerParamVo);

return responseActions;

}



Did this answer your question?