Skip to main content
All CollectionsSystem TasksWorking with Groovy ScriptsGroovy Script Library
Groovy Script - Control options on 'Edit Status' screen
Groovy Script - Control options on 'Edit Status' screen
Updated today

Description: Sample groovy script to control options available on 'Edit Status' screen

Click here for detailed help.

Context: Document

Remark: Accessible in 'On-Load' task mode only

Script:

def execute(){

DocumentVO document = documentService.getDocumentDetails();

String poi = document.getPurposeOfIssue();

String status = document.getStatus();

// Status Change interface options name

String createDiscussionAutomatically = "createDiscussionAutomatically"; //Create Discussion Automatically [ ]

String MarkDocumentRevisionasPrivate = "markDocumentRevisionAsPrivate"; // Mark Document Revision as Private [ ]

String markAllUsersOutstandingTaskComplete = "markAllUsersOutstandingTaskComplete"; // Mark all User's outstanding tasks on this document revision complete (except Comment Incorp) [ ]

String markAllMyOutstandingTaskComplete = "markAllMyOutstandingTaskComplete"; // Mark all my outstanding task on this document revision complete (except Comment Incorp) [ ]

String updateStatusForStaticLink = "updateStatusForStaticLink"; // Update the status for Static Links, Dynamic Links will be updated always []

String reasonForStatusChange = "reasonForStatusChange"; // Reason for Status Change Notes:

JsonArray allStatusWithOptions = new JsonArray();

int PUBLIC = 0; int PRIVATE = 1; int RETAIN_EXISTING = 2;

boolean SELECTED = true; boolean EDITABLE = true; boolean NON_EDITABLE = false;

int CHECKED = 1; int UNCHECKED = 0;

boolean VISIBLE = true; boolean HIDE = false;

if( ( poi.equals("S1") || poi.equals("S2") || poi.equals("S3") || poi.equals("S4") || poi.equals("S5") || poi.equals("S6") || poi.equals("S7")) && status.equals("For Sharing"))

{

JsonObject statusOptions = new JsonObject();

statusOptions.addProperty("status_name", "Please select");

statusOptions.addProperty(IGroovyConstant.SELECTED, true); // This will make this status selected in UI on load

JsonObject selectedFilterObject = new JsonObject();

setStatusOptions(createDiscussionAutomatically, EDITABLE, CHECKED, VISIBLE, selectedFilterObject); //PARAMS: optionName, editable, defaultValue, visible, filterObject

setStatusOptions(markAllUsersOutstandingTaskComplete, EDITABLE, CHECKED, VISIBLE, selectedFilterObject);

setStatusOptions(markAllMyOutstandingTaskComplete, EDITABLE, CHECKED, VISIBLE, selectedFilterObject);

setStatusOptions(MarkDocumentRevisionasPrivate, EDITABLE, PUBLIC, VISIBLE, selectedFilterObject);

setStatusOptions(updateStatusForStaticLink, EDITABLE, CHECKED, VISIBLE, selectedFilterObject);

statusOptions.add(IGroovyConstant.DEFAULT_FILTER,selectedFilterObject);

allStatusWithOptions.add(statusOptions);

JsonObject statusOptions1 = new JsonObject();

statusOptions1.addProperty("status_name", "Shared");

statusOptions1.addProperty(IGroovyConstant.SELECTED, false); // This will make this status selected in UI on load

JsonObject selectedFilterObject1 = new JsonObject();

setStatusOptions(createDiscussionAutomatically, EDITABLE, CHECKED, VISIBLE, selectedFilterObject1); //PARAMS: optionName, editable, defaultValue, visible, filterObject

setStatusOptions(markAllUsersOutstandingTaskComplete, EDITABLE, CHECKED, VISIBLE, selectedFilterObject1);

setStatusOptions(markAllMyOutstandingTaskComplete, EDITABLE, CHECKED, VISIBLE, selectedFilterObject1);

setStatusOptions(MarkDocumentRevisionasPrivate, EDITABLE, PUBLIC, VISIBLE, selectedFilterObject1);

setStatusOptions(updateStatusForStaticLink, EDITABLE, CHECKED, VISIBLE, selectedFilterObject1);

statusOptions1.add(IGroovyConstant.DEFAULT_FILTER,selectedFilterObject1);

allStatusWithOptions.add(statusOptions1);

JsonObject statusOptions2 = new JsonObject();

statusOptions2.addProperty("status_name", "Rejected");

statusOptions2.addProperty(IGroovyConstant.SELECTED, false); // This will make this status selected in UI on load

JsonObject selectedFilterObject2 = new JsonObject();

setStatusOptions(createDiscussionAutomatically, EDITABLE, CHECKED, VISIBLE, selectedFilterObject2); //PARAMS: optionName, editable, defaultValue, visible, filterObject

setStatusOptions(markAllUsersOutstandingTaskComplete, EDITABLE, CHECKED, VISIBLE, selectedFilterObject2);

setStatusOptions(markAllMyOutstandingTaskComplete, EDITABLE, CHECKED, VISIBLE, selectedFilterObject2);

setStatusOptions(MarkDocumentRevisionasPrivate, EDITABLE, PUBLIC, VISIBLE, selectedFilterObject2);

setStatusOptions(updateStatusForStaticLink, EDITABLE, CHECKED, VISIBLE, selectedFilterObject2);

statusOptions2.add(IGroovyConstant.DEFAULT_FILTER,selectedFilterObject2);

allStatusWithOptions.add(statusOptions2);

}

else if( ( poi.equals("A0") || poi.equals("A1") || poi.equals("A2") || poi.equals("A3") || poi.equals("A4") || poi.equals("A5") || poi.equals("A6") || poi.equals("A7")) && status.equals("For Publishing"))

{

JsonObject statusOptions = new JsonObject();

statusOptions.addProperty("status_name", "Please select");

statusOptions.addProperty(IGroovyConstant.SELECTED, false); // This will make this status selected in UI on load

JsonObject selectedFilterObject = new JsonObject();

setStatusOptions(createDiscussionAutomatically, EDITABLE, CHECKED, VISIBLE, selectedFilterObject); //PARAMS: optionName, editable, defaultValue, visible, filterObject

setStatusOptions(markAllUsersOutstandingTaskComplete, EDITABLE, CHECKED, VISIBLE, selectedFilterObject);

setStatusOptions(markAllMyOutstandingTaskComplete, EDITABLE, CHECKED, VISIBLE, selectedFilterObject);

setStatusOptions(MarkDocumentRevisionasPrivate, EDITABLE, PUBLIC, VISIBLE, selectedFilterObject);

setStatusOptions(updateStatusForStaticLink, EDITABLE, CHECKED, VISIBLE, selectedFilterObject);

statusOptions.add(IGroovyConstant.DEFAULT_FILTER,selectedFilterObject);

allStatusWithOptions.add(statusOptions);

JsonObject statusOptions1 = new JsonObject();

statusOptions1.addProperty("status_name", "Published");

statusOptions1.addProperty(IGroovyConstant.SELECTED, true); // This will make this status selected in UI on load

JsonObject selectedFilterObject1 = new JsonObject();

setStatusOptions(createDiscussionAutomatically, EDITABLE, CHECKED, VISIBLE, selectedFilterObject1); //PARAMS: optionName, editable, defaultValue, visible, filterObject

setStatusOptions(markAllUsersOutstandingTaskComplete, EDITABLE, CHECKED, VISIBLE, selectedFilterObject1);

setStatusOptions(markAllMyOutstandingTaskComplete, EDITABLE, CHECKED, VISIBLE, selectedFilterObject1);

setStatusOptions(MarkDocumentRevisionasPrivate, EDITABLE, PUBLIC, VISIBLE, selectedFilterObject1);

setStatusOptions(updateStatusForStaticLink, EDITABLE, CHECKED, VISIBLE, selectedFilterObject1);

statusOptions1.add(IGroovyConstant.DEFAULT_FILTER,selectedFilterObject1);

allStatusWithOptions.add(statusOptions1);

JsonObject statusOptions2 = new JsonObject();

statusOptions2.addProperty("status_name", "Rejected");

statusOptions2.addProperty(IGroovyConstant.SELECTED, false); // This will make this status selected in UI on load

JsonObject selectedFilterObject2 = new JsonObject();

setStatusOptions(createDiscussionAutomatically, EDITABLE, CHECKED, VISIBLE, selectedFilterObject2); //PARAMS: optionName, editable, defaultValue, visible, filterObject

setStatusOptions(markAllUsersOutstandingTaskComplete, EDITABLE, CHECKED, VISIBLE, selectedFilterObject2);

setStatusOptions(markAllMyOutstandingTaskComplete, EDITABLE, CHECKED, VISIBLE, selectedFilterObject2);

setStatusOptions(MarkDocumentRevisionasPrivate, EDITABLE, PUBLIC, VISIBLE, selectedFilterObject2);

setStatusOptions(updateStatusForStaticLink, EDITABLE, CHECKED, VISIBLE, selectedFilterObject2);

statusOptions2.add(IGroovyConstant.DEFAULT_FILTER,selectedFilterObject2);

allStatusWithOptions.add(statusOptions2);

}

if(allStatusWithOptions.size() > 0){

document.setResponseStatus(false);

document.setDynamicObject(allStatusWithOptions.toString());

}

return document;

}

private static setStatusOptions(String optionName, boolean editable, int defaultValue, boolean visible, JsonObject selectedFilterObject) {

JsonObject settingOptions = new JsonObject();

settingOptions.addProperty(IGroovyConstant.EDITABLE, editable);

settingOptions.addProperty(IGroovyConstant.DEFAULT_VALUE, defaultValue);

settingOptions.addProperty(IGroovyConstant.VISIBLE, visible);

selectedFilterObject.add(optionName, settingOptions);

}



Did this answer your question?