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

Ankur Bawiskar
Tera Patron

@LVPhanee 

if you want to restrict from native list or workspace list better to use before update BR and stop the update

In workspace list onCell edit client script and list_edit ACL on field doesn't work

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

I tried with Before BR, but it is still allowing and updated the state from state Closed to open. So opted with ACL is best. 

@LVPhanee 

before update BR should work for Form (Native or Workspace), List (Native or Workspace)

where it didn't work?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

@LVPhanee 

I noticed that the thread has been closed with another response marked as the correct answer.

I had shared my response earlier and believe it addressed the question.

If you don’t mind, could you please share what was missing or could have been improved in my answer?

Your feedback would really help me refine my responses going forward.

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader