- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 04:07 AM
Hi all,
I have created an On change Client script on Incident form, on the field 'Severity'.
I have just written alert(cmdb_ci');
So, on change of Severity field, it should show me alert. Right?
But it is showing error like below:
Please help
Regards,
Lucky
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 04:34 AM - edited 05-19-2024 12:15 PM
Hi @Lucky1,
There's a few things going on under the scenes that you may not be aware of.
First, to retrieve a field value in a Client script you need to leverage the g_form API such as g_form.getValue('field_name'). In addition, when you're trying to retrieve a reference field (which CI is), you need a further step as below - g_form.getDisplayBox('field_name').value - see below as to how to use this.
Use the below onChange Client Script.
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ciDisplayVal = g_form.getDisplayBox('cmdb_ci').value;
alert('Ci val: ' + ciDisplayVal);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 06:18 AM
@Lucky1 , First of all you are missing a beginning single quote and also the proper way to get/alert the field name is
g_form.getValue('field_name');
Mark my response helpful if it helped you.