g_form.removeOption() is not working in multirow variable set catalog client script.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
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
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
you are using wrong method removeOptionByLabel
correct one is this
g_form.removeOption('actor_type', 'choice value'); // give your choice value
💡 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 || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
