- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2023 05:08 AM
Hi
I have a requirement when the configuration item on a change request is chosen with certain value then various fields in the form should be auto populated.
I've been looking to achieve this with a client script set to onChange on the configuration item field. I currently have it adding to the blackout plan but this happens for all new configuration item values and not just the required value.
Here's my script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Populate backout plan details
var configitem = g_form.getValue('cmdb_ci').name;
if(configitem = 'Firewall') {
g_form.setValue('backout_plan', 'This is sample text that will be autopopulated');
}
}
What do I need to amend to get this to only populate when the Firewall record is chosen as the new value?
thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2023 05:12 AM - edited 11-03-2023 06:14 AM
Hi,
Try this
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Populate backout plan details
var configitem = g_form.getDisplayBox('cmdb_ci').value; //this is how you can get the display value of a reference field on client side
if(configitem == 'Firewall') {
g_form.setValue('backout_plan', 'This is sample text that will be autopopulated');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2023 05:12 AM - edited 11-03-2023 06:14 AM
Hi,
Try this
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Populate backout plan details
var configitem = g_form.getDisplayBox('cmdb_ci').value; //this is how you can get the display value of a reference field on client side
if(configitem == 'Firewall') {
g_form.setValue('backout_plan', 'This is sample text that will be autopopulated');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2023 05:13 AM - edited 11-03-2023 05:21 AM
Replace
if(configitem = 'Firewall') {
with
if(configitem == 'Firewall') {
Ideal, will to use GlideAjax. However, you can try below.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Populate backout plan details
var configitem = g_form.getReference('cmdb_ci',callback);
function callback(configitem)
if(configitem.name == 'Firewall') {
g_form.setValue('backout_plan', 'This is sample text that will be autopopulated');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2023 07:36 AM
Thanks Jaspal this also works as an alternative to Anurag's solution.
You mention that more ideal is to Use GlideAjax though. Why is that?