Roles value visible based on Client values on catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi Everyone,
I have one requirement on Catalog item
--In catalog item having two variable, Client and Roles and roles having the option Functional and Basis and Client Having the options DS4 100 and DS4 200 ,DCA 100. If i select Functional in Roles then DS4 100 and DS4 200 and DCA 100 visible only (others not)and i i select Basis in Roles then in Client only visible DS4 100, DS4 200(only others not visible)for this i want to on change client script in serviecnow.
--same time if i Development option in scape variable and S4 option in System variable then DS4 100 and DS4 200 options only visible in client variable.
Please help me write on-change client script on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
it's an easy requirement.
what did you start with and where are you stuck?
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
16m ago - last edited 11m ago
Hi @Manohararuna
Create Catalog Client Script > onChange
Roles:
(function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || !newValue) return;
var options = [];
if (newValue === 'Functional') {
options = ['DS4 100', 'DS4 200', 'DCA 100'];
} else if (newValue === 'Basis') {
options = ['DS4 100', 'DS4 200'];
}
g_form.clearOptions('client');
g_form.addOption('client', '', '-- None --');
options.forEach(function(opt) {
g_form.addOption('client', opt, opt);
});
})();
System
(function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) return;
var scape = g_form.getValue('scape');
var system = g_form.getValue('system');
if (scape === 'Development' && system === 'S4') {
var options = ['DS4 100', 'DS4 200'];
g_form.clearOptions('client');
g_form.addOption('client', '', '-- None --');
options.forEach(function(opt) {
g_form.addOption('client', opt, opt);
});
}
})();
Doing so helps other users find accurate and useful information more easily.