Skip to main content

Conditional Status Change

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

Updated over 3 weeks ago

Asite Visual Workflow enables users to configure and control interface options on the edit file status function. Click 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 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 the selected status’s value and default status to be changed.

Workflow can be configured by following the below steps:

1. Pre-requisites

To set up the edit status page, the necessary attributes must be present in the project.

Click here to learn how to define the purpose of issuing files in a project.
Click here to learn how to define file statuses in a project.
Click here to learn 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 the system task name.

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

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

3. Configure Groovy Script
You can set up the following Groovy script according to the required results and add it to the newly created system task. The following configurations can be included in the Groovy script:

Availability of values within the 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);

}

The above-mentioned groovy script is divided into logical sections as mentioned below:

Script

Description

def execute(){

DocumentVO document = documentService.getDocumentDetails();

String poi = document.getPurposeOfIssue();

String status = document.getStatus();

This script section defines the attributes used for the combination in the Groovy script. It can include standard and custom attributes. (In the case of the custom attribute, add the script to fetch the list of custom attributes (Click here for reference) then define the custom attribute’s name.

Create an alias name and attribute function to retrieve the values of the 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 the 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.

The following are the options added in the 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 tasks 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 section of the script is not to 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 script section defines the configuration options for the above-mentioned setting options. Within the Groovy script, the user can use appropriate options from the given sample script:

PUBLIC = 0, Mark all selected documents as public

PRIVATE = 1 Mark all selected documents as private.

RETAIN_EXISTING =2 Retain existing access level.

EDITABLE = true, system allows to edit the option

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

CHECKED = 1, the default option is displayed enabled (Checked)

UNCHECKED = 0, the default option is displayed disabled (unchecked)

VISIBLE = true, the system displays an option on the interface

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

This section of the script is not to 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 section of the script defines the combination of values from the attributes defined in the above script.

The script can be created by adding alias names of one or more attributes, defined in the above script with the attribute’s value.

Or and & condition can be used to create a combination. The format of the 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 the given sample script,

poi = Attribute’s alias name defined in the 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 the 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 section of the script defines,

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

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

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

4. Configuration of setting options based on the selected value.

The format of the script is mentioned 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 opening the 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 displayed by default

false = Selected value is not displayed by default. The value will be available in the 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 the attribute’s values when the above-mentioned does not match.

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

The format of the 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 the given sample script,

poi = Attribute’s alias name defined in the 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 the 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 section of the script defines functions for the following configuration as defined for the above combination,

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

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

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

4. Configuration of setting options based on the selected value.

The format of the script is the same as mentioned for the above combination,

In the given sample script,

1. For the availability of values while opening the 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. The value will be available in the dropdown.

3. Options and configurations are the same as above.

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 section of the Groovy script returns the logical values to the system and is used to display the response.

This section of the script is not to 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 the 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 be invoked.

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

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

Task - Select the name of the above-created Groovy script.

This will invoke the configured system task when the condition is matched and the user tries to update the status for the 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

The 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 the above 'Drawing' folder, a drawing is uploaded with the POI as 'S1' and status as 'For Sharing'. The privileged users can go to the 'Files' tab, right-click on the 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 the status value as ‘Rejected’, the ‘Create discussion automatically’ option will get unchecked as defined in the script:



Did this answer your question?