Skip to main content
All CollectionsSystem TasksWorking with Groovy ScriptsGroovy Script Library
Groovy Script - Distribute Files based on Due Date
Groovy Script - Distribute Files based on Due Date
Updated today

Description: Sample Groovy script to distribute files based on due date. You are able to specify whether the distribution should be based on a specific due date, while distributing to individual users, roles or organizations.

Context: Document

Remark: Accessible in 'Post' task mode only

Script:

// Distribute file to users, roles, orgs and group by dueDate

def execute(){

distributeFileToUsers("For Status Change", "user1@example.com", "20-Jul-2024", "true");

distributeFileToRoles("For Status Change", "Role A,Role B", "21-Jul-2024", "true");

distributeFileToOrgs("For Status Change", "Example 1 Company,Example 2 Company", "22-Jul-2024", "true");

distributeFileToGroups("Group A");

}

// Method used to distribute file to provided emailIds

// 1. Action to be distributed 2. user email(s) 3. Action due date 4. send Email Notification true/false

def distributeFileToUsers(def actionName, def distributionList, def actionDueDate, def isSendNotification = "false"){

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

distributeFile.put("actionName", actionName);

distributeFile.put("distributionList", distributionList);

distributeFile.put("isSendNotification", isSendNotification);

distributeFile.put("distributionType", "1");

distributeFile.put("actionDueDate", actionDueDate);

return documentService.distributeFile(distributeFile);

}

// Method used to distribute file to provided rolenames

// 1. Action to be distributed 2. role name(s) 3. Action due date 4. send Email Notification true/false

def distributeFileToRoles(def actionName, def distributionList, def actionDueDate, def isSendNotification = "false"){

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

distributeFile.put("actionName", actionName);

distributeFile.put("distributionList", distributionList);

distributeFile.put("isSendNotification", isSendNotification);

distributeFile.put("distributionType", "2");

distributeFile.put("actionDueDate", actionDueDate);

return documentService.distributeFile(distributeFile);

}

// Method used to distribute file to provided org names

// 1. Action to be distributed 2. Org name(s) 3. Action due date 4. send Email Notification true/false

def distributeFileToOrgs(def actionName, def distributionList, def actionDueDate, def isSendNotification = "false"){

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

distributeFile.put("actionName", actionName);

distributeFile.put("distributionList", distributionList);

distributeFile.put("isSendNotification", isSendNotification);

distributeFile.put("distributionType", "3");

distributeFile.put("actionDueDate", actionDueDate);

distributeFile.put("isOrgName", "true");

return documentService.distributeFile(distributeFile);

}

// Method used to distribute file to provided group names

def distributeFileToGroups(def distributionList){

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

distributeFile.put("actionName", "For Status Change");

distributeFile.put("distributionList", distributionList);

distributeFile.put("distributionType", "4");

return documentService.distributeFile(distributeFile);

}



Did this answer your question?