Description: Sample Groovy Script to set the due date of a specific timer in the workflow by fetching the date from the document's custom attribute.
Context: Document
Document Type: File
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;
}
