User should not change the status value from list view

vasireddyra
Tera Contributor
Hi All,
 
I have written script in display business rule it is working  for list view it is throwing error message and status is not changing for existing records but in form view when I try to change status for existing records when save it is throwing error message and invalid insert and state is getting updated.
 
someone please check and suggest code changes
 
if (current.booking_status.changes()) {
        gs.addErrorMessage("Booking Status can't be changed.");
        current.setAbortAction(true);
    }
 
 
 
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@vasireddyra 

you should use before insert/update BR so that it works on form since you want to stop the form submission

OR Another best way

why not restrict it using ACL?

1) create list_edit ACL for that field and use advanced script and give answer=false;

2) also create field level WRITE ACL and use advanced script and give answer=false;

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@vasireddyra 

you should use before insert/update BR so that it works on form since you want to stop the form submission

OR Another best way

why not restrict it using ACL?

1) create list_edit ACL for that field and use advanced script and give answer=false;

2) also create field level WRITE ACL and use advanced script and give answer=false;

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

vasireddyra
Tera Contributor

Thank you For Your Respnse @Ankur Bawiskar 

                   I have tried insert?update BR it is not working status is getting updated, after that I have tried ACL like you suggested it is working fine.

 

Regards 

Raveena

vasireddyra
Tera Contributor

Thank you for your Response @Ankur Bawiskar 

 

                    I have tried insert/update BR but it is not working status is getting updated ,After that i have tried ACL like you suggested it is working fine.

 

Regards

Raveena