Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

change state edit in list form

sai190
Tera Contributor

hi.

can anyone help me with the requirment, i have written business rule for the change state where only change manager can be editable in list view, person who has admin and change manager need to edit the 2 fields, person only with admin should not edit the two values.

i have written before business rule and condition as state changes.

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

    if ((current.state == '3' || current.state == '14') && !gs.hasRoleExactly('change_manager')) {
        gs.addErrorMessage("You are not authorized to change the state to Closed Successful/Closed with Defects.");
        current.setAbortAction(true);
    }

})(current, previous);

person with change manager and admin need to editable values of 3 and 4

1 ACCEPTED SOLUTION

Finally done
change the script with this if problem still persist then turn off the data policy and try 

function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
  var saveAndClose = false;
 //Type appropriate comment here, and begin script below
 var canResolve = true;
var chg = !(g_user.hasRoleExactly('change_admin'));   
if ((newValue == "6" || newValue == "7") && chg) { 
alert(chg);
alert("You are not authorized to change the state to In Progress.");   
canResolve = false;   
} 
 callback(saveAndClose); 
}

 

Ignore the alert message i was using old one

find_real_file.png

 

Do Mark Correct and Helpful if it works.


***Mark Correct or Helpful if it helps.***

View solution in original post

10 REPLIES 10

Aman Kumar S
Kilo Patron

Hi @sai

I am sure you are very eager to resolve this, but please keep queries limited to one thread

Best Regards
Aman Kumar

its sitting on my head since 4 days

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

then why not have list_edit ACL on that state field?

Admin Overrides - True

Roles - change_manager

Regards
Ankur

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

list cell edit is making complete state field read only but i want only change manager with admin role and only change manager can select those 3 and 14, rest pf the options of the state field can be change able by anyone. it would be helpful if you can help me with acl script