Show Hide choice based on User

Sai Sree
Tera Contributor

I have a requirement, I have a Select Box Variable and 10 choices, 'Requested For User' selected one choice in SC TASK and once SC TASK completed I have to make it that choice Inactive true in Question Choice table.

And once 'Requested For User' status changes to 'T' in Sys User Table, I have to make it that choice Inactive false in question choice table.

How to do it in service now ?

2 REPLIES 2

Pooja2998
Mega Sage

Hello @Sai Sree 

You can create one business rule: After an update, add the condition for the state to changeTo "Close Complete." 

Pooja2998_0-1740036338039.png

 
Add Below code:
(function executeRule(current, previous /*null when async*/) {
var ch = current.variables.choice;
var qcGr = new GlideRecord('question_choice');
qcGr.addQuery('value', ch);
qcGr.query();
if (qcGr.next()) {
    qcGr.inactive = true;  
    qcGr.update();  
}

})(current, previous);

If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Pooja.
Add this code:

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

@Sai Sree 

Why to make that choice as inactive? What if some other user wants to submit catalog item with that choice on portal?

what's the meaning of this line -> And once 'Requested For User' status changes to 'T' in Sys User Table, I have to make it that choice Inactive false in question choice table.

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