Skip to main content
Conditional Status Change

This article explains how to configure edit status change, system tasks and groovy scripts.

Updated over 2 weeks ago

Asite Visual Workflow enables users to configure and control interface options on the edit file status function. Click on the below links to access their detailed help:


A. Configure Edit Status Page

Users can configure a workflow, to control the values available for updating the status and configuring available options such as 'Create Discussion Automatically', 'Mark Document Revision as Private', 'Clear own/all user’s incomplete tasks on revision', etc.

Workflow provides flexibility on the visibility of setting options based on selected status’s value and default status to be changed.

Workflow can be configured by following below steps:

1. Pre-requisites

In order to configure edit status page, Required attributes should be available on the project.

Click here to understand how to define purpose of issues in a project.
Click here to understand how to define file statuses in a project.
Click here to understand how to define custom attributes in a project.

2. Configure System Task

Select your desired project and ‘Configure System Task’ with the following details:

Name - Enter system task name.

Task Context - Select context type as ‘Document’ from the dropdown.

Task - Select task ‘Execute Groovy Script’ from the dropdown.

3. Configure Groovy Script
Configure following groovy script as per the required results and add within newly created system task. Following configurations can be included in groovy script:

Availability of values within edit status page
Default status value to be selected
Availability of setting options based on selected values
Manage setting options based on values - visibility, allow editing or not

def execute(){

DocumentVO document = documentService.getDocumentDetails();

String poi = document.getPurposeOfIssue();

String status = document.getStatus();

// Status Change UI 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);

}

Above mentioned groovy script is divided into logical parts as mentioned below:

Script

Description

def execute(){

DocumentVO document = documentService.getDocumentDetails();

String poi = document.getPurposeOfIssue();

String status = document.getStatus();

This part of script is to define the attributes that are being used for the combination in groovy script. User can define standard as well as custom attributes. (In case of custom attribute, add the script of fetching the list of custom attributes (Click here for reference) then define custom attribute’s name.

Create an alias name and attribute function to retrieve the values of defined attribute, sample format is as mentioned below,

String <<Alias Name>> = document.get<<Attribute Name>>();

String <<Alias Name>> = document.get<<Attribute Name>>();

In script code, given attributes are used for retrieving the value:

poi = Alias name

document.getPurposeOfIssue = To retrieve values of purpose of issues from the project

status = Alias name

document.getStatus = To retrieve values of statuses from the project

// Status Change UI 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:

This function is used to define the list of setting options, to use in the groovy script.

Following are the options added in sample script:

1. Create discussion automatically

2. Mark document revision as private

3. Mark all user's outstanding tasks on this document revision complete (except 'For Comment Incorporation')

4. Mark all my outstanding task on this document revision complete (except 'For Comment Incorporation')

5. Update the status for Static Links, Dynamic Links will be updated always

6. Reason for Status Change

This part of script is not be edited, and is to be used as is.

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;

This part of script defines the configuration options for the above mentioned setting options. Within groovy script, user can use appropriate options from the given sample script:

PUBLIC = 0, Mark all selected documents public

PRIVATE = 1 Mark all selected documents private.

RETAIN_EXISTING =2 Retain existing access level.

EDITABLE = true, system allows to edit the option

NON_EDITABLE = false, system is not allowed to edit the option

CHECKED = 1, default option is displays enabled (Checked)

UNCHECKED = 0, default option is displays disabled (unchecked)

VISIBLE = true, system displays option on the interface

HIDE = false, system doesn't display option on the interface

This part of script is not be edited, and is to be used as is.

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"))

This part of script defines the combination of values from the attributes defined in above script.

Script can be created by adding one or multiple attribute’s alias name, defined in above script with the attribute’s value.

Or and & condition can be used to create a combination. Format of script is as mentioned,

if( ( <<Attribute’s Alias Name>>.equals(“<<Attribute’s value1>>”) || <<Attribute’s Alias Name>>.equals("<<Attribute’s value1>>") && <<Attribute’s Alias Name>>.equals("Attribute’s value1"))

In given sample script,

poi = Attribute’s alias name defined in script above

(“S1”), (“S2”), (“S3”), (“S4”), (“S5”), (“S6”), (“S7”), = Values created within purpose of issue of the project

|| = OR condition to create the combination of values

&& = AND condition to create the combination of values

status = 2nd Attribute’s alias name defined in script above

(“For Sharing”) = Values created as file status in the project.

{

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);

}

This part of script defines,

1. Default selected value of status when user opens the edit status page.

2. Availability of status values to select from the dropdown of edit status page.

3. Default configuration of setting options based on selected value.

4. Configuration of setting options based on selected value.

Format of script is mentioned as below,

statusOptions.addProperty("<<status_name", "<<Please select/Status value>>");

JsonObject selectedFilterObject = new JsonObject();

setStatusOptions(<<Setting Option’s name>>, <<Configuration option 1>>, <<Configuration option 2>>, selectedFilterObject);

setStatusOptions((<<Setting Option’s name>>, <<Configuration option 1>>, <<Configuration option 2>>, selectedFilterObject);

In the given sample script,

1. For the availability of values while open edit status page,

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

Added value = Please select, Shared

2. To set the default selected value

statusOptions.addProperty(IGroovyConstant.SELECTED, true);

true = Selected value is display default selected

false = Selected value is not display by default. Value will be available in dropdown

3. Setting options and their configuration

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

Setting Options = createDiscussionAutomatically, markAllUsersOutstandingTaskComplete , markAllMyOutstandingTaskComplete MarkDocumentRevisionasPrivate, updateStatusForStaticLink

Configuration options = Editable, NON_EDITABL, CHECKED, UNCHECKED, VISIBLE , HIDE

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

This script defines the alternate combination of attribute’s values when above mentioned combination do not match.

The process of defining the condition is same as first one. Refer <<Link if condition section>>

Format of script is as mentioned,

else if ( ( <<Attribute’s Alias Name>>.equals(“<<Attribute’s value1>>”) || <<Attribute’s Alias Name>>.equals("<<Attribute’s value1>>") && <<Attribute’s Alias Name>>.equals("Attribute’s value1"))

In given sample script,

poi = Attribute’s alias name defined in script above

(“A0”), (“A1”), (“A2”), (“A3”), (“A4”), (“A5”), (“A6”), = Values created within purpose of issue of the project

|| = OR condition to create the combination of values

&& = AND condition to create the combination of values

status = 2nd Attribute’s alias name defined in script above

(“For Publishing”) = Values created as file status in the project.

{

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", "Published");

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);

}

This part of script defines functions for following configuration as defined for above combination,

1. Default selected value of status when user opens the edit status page

2. Availability of status values to select from the dropdown of edit status page

3. Default configuration of setting options based on selected value.

4. Configuration of setting options based on selected value.

Format of script is same as mentioned for above combination,

In the given sample script,

1. For the availability of values while open edit status page,

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

Added value = Please select, Published

2. To set the default selected value

statusOptions.addProperty(IGroovyConstant.SELECTED, true);

true = Selected value displays by default selected

false = Selected value doesn't display by default. Value will be available in dropdown

3. Setting options and their configuration are same as for above mentioned combination.

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);

}

This part of groovy script returns the logical values back to the system. And is used to display the response.

This part of script is not be edited, and is to be used as is.

4. Create Trigger
Once the system task is configured, create a new ‘Trigger’ on the selected project with following details:

Add Details - Add all the trigger details including name, description, priority and conditions with the context as ‘Document’.

Condition - Folder/Status/POI on which trigger can invoke.

Event - Select the trigger event as ‘Change Status’.

Task Mode - Select task mode as ‘On-Load’. (On-load mode allow user to edit the status and available setting options on user interface).

Task - Select the name of above created groovy script.

This will invoke the configured system task when the condition is matched and user tries to update status for selected file.


B. Example

Folder Name - Drawings

Purpose of Issue - A0, A1, A2, A3, A4,A5, S1, S2, S3, S4, S5

Status - For Sharing, Shared, Rejected, For Publishing, Published

Trigger condition - Folder: Drawing and Status = For Sharing

System task is created with the below groovy script:

def execute()

{

DocumentVO document = documentService.getDocumentDetails();

String poi = document.getPurposeOfIssue();

String status = document.getStatus();

// Status Change UI 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 []

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")) && 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, UNCHECKED, 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")) && 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);

}

In above 'Drawing' folder, a drawing is uploaded with the POI as 'S1' and status as 'For Sharing'. Privileged user can go to 'Files' tab, then right click on file name and select 'Edit > Status' to update the status as per the groovy script and options.

Output

Default screen and availability of options based on combination:

By selecting status value as ‘Rejected’, ‘Create discussion automatically’ option will get unchecked as defined in the script:



Did this answer your question?