We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

g_form.removeOption() is not working in multirow variable set catalog client script.

GopiKrishna Sir
Tera Contributor

We have a catalog client script on MRVS to hide drop choice based on users cost center. But choice is not getting removed even after adding a catalig client script.

Sample code : 

var allowedCC = 'a6754a8b97438a505f88b3a3f153afe5';
    var ga = new GlideAjax('GetUserCostCenter');
    ga.addParam('sysparm_name', 'getCostCenter');
    ga.addParam('sysparm_user', g_user.userID);
    alert(g_user.userID);
    ga.getXMLAnswer(function (cc) {
        alert(cc);
        // Optional: handle empty values or server error
        if (!cc) {
            console.warn('No cost center returned');
            return;
        }
       
        // Only run if user does NOT have allowed cost center
        if (cc !== allowedCC) {
            // Remove the specific option by label
            g_form.removeOptionByLabel('actor_type', 'Central F&A Actor Packages');
        }
    });
 
Did anyone faced similar issue & found work around, Please let us know to solve it.
Thanks
Gopi
6 REPLIES 6

I have used 'g_sc_form.removeOption('test_var', 'choice_one');' unfortunately it didn't removed choice value. 

@GopiKrishna Sir 

please share some screenshots and complete script without which can't help

💡 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