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 weeks 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 weeks 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
3 weeks ago
Hi Ankur,
Actuallay my end user trying to select multiple option.So i just change the variable type from Slect box to List Collector
1-reuirement-Landscape - Sandbox
Roles - it support and functional support
Client - 300 and 450
2.requirement-Landscape - Development
Client - 100 and 200
3-Requirement-I f role having the option-
DS4 100 DS4 200 DCA 100
Functional Yes Yes Yes
Cross Functional Yes Yes
(CAR and S4) Y
Security Yes Yes Yes
Basis Yes Yes Yes
Development Yes Yes Yes
Fiori Administration Yes Yes Yes
CAR Configurator Yes
for this i written the client script and Script include. below
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Manohararuna
In your case the best approach is create a Catalog Client Scrip > OnChange for Roles, Scape and System
Role
(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);
});
})();
Scape and 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);
});
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks 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);
});
}
})();