Skip to main content

Groovy Script - Retrieve Incomplete or Pending Actions on Files

Description: Groovy script to retrieve the list of incomplete or pending actions for users of the current document. This script must be directly used with a trigger and within a visual workflow service task.

Context: Document

Remark: Accessible in Post task mode only.

Script:

def execute(){
/*
1) List of User type option for incomplete task

GroovyConstant.GET_PENDING_TASKS_ASSIGNED_BY_ALL_USERS -- For all users data
IGroovyConstant.GET_PENDING_TASKS__ASSIGNED_BY_WORKLOW_AGENT -- For system user data only
IGroovyConstant.GET_PENDING_TASKS_MANUALLY_ASSIGNED -- For all user except system user means all manual user data

2) Action Type option for incomplete task

IGroovyConstant.ALL_INCOMPLETE_ACTIONS --For all incomplete action

-- For perticuler single action
ISystemConstants.ACTION_FOR_ACKNOWLEDGEMENT
ISystemConstants.ACTION_FOR_COMMENT
ISystemConstants.ACTION_FOR_COMMENT_APPROVAL
ISystemConstants.ACTION_FOR_COMMENT_INCORP
ISystemConstants.ACTION_FOR_DISTRIBUTION
ISystemConstants.ACTION_FOR_INFORMATION_DOCUMENT
ISystemConstants.ACTION_FOR_STATUS_CHANGE
ISystemConstants.ACTION_FOR_PUBLISHING
ISystemConstants.ACTION_DOCUMENT_FOR_ACTION

Return UserActionVO contain following feild we can use it in groovy.

UserActionVO.getActionID(),
UserActionVO.getEmail(),
UserActionVO.getLname(),
UserActionVO.getFname(),
UserActionVO.getActionName(),
UserActionVO.getOrgName()
UserActionVO.getAssignedDate()
UserActionVO.getAssignedByUserEmail();
UserActionVO.getActionDueDate()

*/
int aDecisionVaribale = 0;
boolean aDecisionUpdateRequired = false;
List<UserActionVO> actionList = documentService.getIncompleteActionList (IGroovyConstant.GET_PENDING_TASKS_ASSIGNED_BY_ALL_USERS,IGroovyConstant.ALL_INCOMPLETE_ACTIONS);

Set<Integer> actions = new HashSet<>();
for(UserActionVO userActionVO:actionList){
actions.add(userActionVO.actionID);
}

if(actions.contains(ISystemConstants.ACTION_FOR_ACKNOWLEDGEMENT)){
aDecisionVaribale=1;
aDecisionUpdateRequired = true;
}else if (actions.contains(ISystemConstants.ACTION_FOR_COMMENT)){
aDecisionVaribale=2;
aDecisionUpdateRequired = true;
}else if (actions.contains(ISystemConstants.ACTION_FOR_STATUS_CHANGE)){
aDecisionVaribale=3;
aDecisionUpdateRequired = true;
}else{
aDecisionVaribale=4;
aDecisionUpdateRequired = true;
}

if(aDecisionUpdateRequired){
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?