- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2018 08:45 AM
I would like to create an OnChange Client Script for the Incident form.
When the location changes I need the Configuration Item to be cleared out, this has to work before a save/update is done.
Can someone help me write this as I am not good with scripting. TIA!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2018 08:51 AM
In the script field on an onChange client script, you just need to do:
g_form.clearValue('cmdb_ci');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2018 11:42 AM
How do you have your client script set up? It might help to include a screenshot of the client script so we can see the settings for when to run.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2018 11:47 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2018 11:49 AM
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//check to see if the value has truly changed
if(oldValue != newValue){
//clear the value of field below
g_form.clearValue('cmdb_ci');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2018 11:59 AM
Thank you, that worked but now once I select a new location and a new CI when I save it clears the CI out again. If i change a second time it keeps it. So I'm having to double save to keep the changes when I select a new location. Any suggestions?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2018 12:04 PM
That sounds odd, the script should only run when you change Location, if you've kept the same settings and just updated the script