on Sc_task table when the state is closed, in SCtask list it is allowing to re-open. in-line editing

LVPhanee
Tera Contributor

i have a requirement in SC_TASK

Assignment group : ABC 

state : Cancelled  / Completed

 

Either in the SC_TASK form or in the SCTASK list ( inline editing) should not happen. 

 

For SC_TASK form applyed UI policy -> read only once the state is changed to cancelled or completed. But manager is changing it from SCTASK list ( Servicenow system is allowing). 

can any one of you suggest ACL for the above requirement. 

what i have done is:
1. create a new ACL
type : record
operation : write 
decision type : Deny unless
name : Sc_task -------field : State

Applied to: blank 
Roles: given X_abc_role (custom role create for a scoped application table)
 Data condition: State -- is not one of -- ( selected closed complete and cancelled) and

                                  assignment group  -- is -- ABC


1 ACCEPTED SOLUTION

Tanushree Maiti
Tera Patron

Hi @LVPhanee 

 

Step 1: Create a before insert/update BR

 

  • Navigate to System Definition > Business Rules and click New.
  • Fill out the form:
    • Name: Restrict Edits on Completed/Cancelled ABC Tasks
    • Table: Catalog Task (sc_task)
    • Active: Checked
    • Advanced: Checked
  • Under the When to run tab, configure the following conditions:
    • When: Before
    • Insert: Checked
    • Update: Checked
    • Filter Conditions:
      • Assignment group is Assignment group ABC
      • State is one of Closed Complete, Closed Incomplete, Closed Skipped, Cancelled
  • Under the Actions tab, set the Task update message:
    • Abort action: Checked
    • Add message: You cannot edit this task because it is already Completed or Cancelled.
  • In the Script tab, paste the following code:

 

(function executeRule(current, previous /*null when async*/) {

        gs.addErrorMessage(gs.getMessage('You cannot edit this task because it is already Completed or Cancelled.'));

    current.setAbortAction(true);

})(current, previous);

 

 

Step 2: Create a List_edit ACL

 

 

Navigate to System Security > Access Control (ACL) and click New.

Fill out the ACL:

  • Type: record
  • Operation: list_edit
  • Name: sc_task (Select sc_task.* )  //do not select any field

In the Requires role list, add the roles that should bypass this restriction (e.g., admin).

In the Condition builder, define the restriction so that it is only editable when the task is not closed:

  • State is one of Closed Complete, Closed Incomplete, Closed Skipped, Cancelled

 

In advance script, answer = false;

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

View solution in original post

5 REPLIES 5

Tanushree Maiti
Tera Patron

Hi @LVPhanee 

 

Step 1: Create a before insert/update BR

 

  • Navigate to System Definition > Business Rules and click New.
  • Fill out the form:
    • Name: Restrict Edits on Completed/Cancelled ABC Tasks
    • Table: Catalog Task (sc_task)
    • Active: Checked
    • Advanced: Checked
  • Under the When to run tab, configure the following conditions:
    • When: Before
    • Insert: Checked
    • Update: Checked
    • Filter Conditions:
      • Assignment group is Assignment group ABC
      • State is one of Closed Complete, Closed Incomplete, Closed Skipped, Cancelled
  • Under the Actions tab, set the Task update message:
    • Abort action: Checked
    • Add message: You cannot edit this task because it is already Completed or Cancelled.
  • In the Script tab, paste the following code:

 

(function executeRule(current, previous /*null when async*/) {

        gs.addErrorMessage(gs.getMessage('You cannot edit this task because it is already Completed or Cancelled.'));

    current.setAbortAction(true);

})(current, previous);

 

 

Step 2: Create a List_edit ACL

 

 

Navigate to System Security > Access Control (ACL) and click New.

Fill out the ACL:

  • Type: record
  • Operation: list_edit
  • Name: sc_task (Select sc_task.* )  //do not select any field

In the Requires role list, add the roles that should bypass this restriction (e.g., admin).

In the Condition builder, define the restriction so that it is only editable when the task is not closed:

  • State is one of Closed Complete, Closed Incomplete, Closed Skipped, Cancelled

 

In advance script, answer = false;

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti