Skip to main content
All CollectionsSystem TasksWorking with Groovy ScriptsGroovy Script Library
Groovy Script - Distribute Files based on Number of Due Days
Groovy Script - Distribute Files based on Number of Due Days
Updated over a month ago

Description: Sample Groovy script to distribute files based on due days. You are able to specify whether the distribution should be based on number of due days, 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 dueDays

def execute(){

distributeFileToUsers("For Status Change", "user1@example.com", "10", "true");

distributeFileToRoles("For Status Change", "Role A,Role B", "10", "true");

distributeFileToOrgs("For Status Change", "Example 1 Company,Example 2 Company", "2", "true");

distributeFileToGroups("Group A");

}

// Method used to distribute file to provided emailIds

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

def distributeFileToUsers(def actionName, def distributionList, def actionDueDays, 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("actionDueDays", actionDueDays);

return documentService.distributeFile(distributeFile);

}

// Method used to distribute file to provided rolenames

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

def distributeFileToRoles(def actionName, def distributionList, def actionDueDays, 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("actionDueDays", actionDueDays);

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 days 4. send Email Notification true/false

def distributeFileToOrgs(def actionName, def distributionList, def actionDueDays, 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("actionDueDays", actionDueDays);

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?