Skip to main content
All CollectionsSystem TasksWorking with Groovy ScriptsGroovy Script Library
Groovy Script - Distribute Files based on Email ID
Groovy Script - Distribute Files based on Email ID
Updated this week

Description: Sample groovy script to distribute files based on user's email address

Context: Document

Remark: Accessible in 'Post' task mode only

Script:

/*

Parameters:

[A] actionName: "For Status Change"

[B] revisionIds: If you want to apply on active version of file then value should be blank, otherwise "revision_id"

[C] distributionList: Value changes as per distributionType. distributionType are listed below:

1) distributionType value : "1" [distribution based on email id - need to set email id's separated by semicolon in distributionList field (e.g. user1@asite.com;user2@asite.com)]

2) distributionType value : "2" [distribution based on Roles Name - need to set Roles Name separated by commas in distributionList field (Ex : Role1,Role2)]

3) distributionType value : "3" [distribution based on Organisation Id - need to set Org Id separated by commas in distributionList field (Ex : OrgId1,OrgId2)]

4) distributionType value : "4" [distribution based on Group Name so need to set Group Name separated by commas in distributionList field (Ex : GroupName1,GroupName2)]

[D] actionDueDate: If you want to apply current date as Task Due Date then value can be left blank, otherwise set a specific Task Due Date in the format "20-Jul-2017"

[E] actionDueDays: The value entered for actionDueDays will be considered to calculate task due date. While calculating task due date, any weekly off's or holidays as defined in working calendar will also be considered.

[F] isForPlaceHolder: When you want to distribute on placeholder, value must be set to true otherwise set the value as false.

[G] isSendNotification: If you want to send email notification for distribution task, set the value as true otherwise set the value as false.

[H] distributionType: There are four types available for distribution.

1) Based on Email Id

2) Based on Roles Name

3) Based on Organisation Name

4) Based on Group Name

*/

def execute(){

distributeFile("For Status Change","","user1@example.com;user2@example.com", "20-Jul-2017","10","false","true","1");

}

def distributeFile(def actionName ,def revisionIds , def distributionList, def actionDueDate , def actionDueDays, def isForPlaceHolder , def isSendNotification ,def distributionType){

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

distributeFile.put("actionName", actionName);

distributeFile.put("revisionIds", revisionIds);

distributeFile.put("distributionList", distributionList);

distributeFile.put("actionDueDate", actionDueDate);

distributeFile.put("isForPlaceHolder", isForPlaceHolder);

distributeFile.put("isSendNotification", isSendNotification);

distributeFile.put("distributionType", distributionType);

distributeFile.put("actionDueDays", actionDueDays);

return documentService.distributeFile(distributeFile);

}



Did this answer your question?