- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2015 08:45 AM
I am developing an incident request form that uses:
- a record producer to create incident requests.
- a variable set that includes the caller's name (a reference field), short description (text field), description (text field), etc.The variable set also has an employee id number (text field)
- an OnChange catalog client script on the variable set that auto-fills the caller name based on what is entered in the employee id field.
If I submit the form by just typing in the caller's name in to the reference field the caller properly gets set in the record upon creation.
However, if I submit the form using the auto-filled field the caller gets left empty.
I can't seem to figure out why this is happening. In my record producer script I set the incident field using the following code:
current.short_description = producer.short_description;
current.description = producer.description;
current.caller_id = producer.caller_name;
The description and short descriptions get set just fine on submission. Why isn't my caller being set?
As I mentioned this only occurs when the caller name is auto-filled on the form using the id number.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2015 09:03 AM
Can I have a look at the onChange script? Are you using the sys_id of the user to auto-fill the caller name (i.e. the reference type variable)?
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2015 09:03 AM
Can I have a look at the onChange script? Are you using the sys_id of the user to auto-fill the caller name (i.e. the reference type variable)?
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2015 10:14 AM
Here's my script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var user = new GlideRecord('sys_user');
user.addQuery('employee_number', newValue);
user.query();
if(user.next()){
g_form.setValue('caller_name',user.name);
}
}
I'm using the name of the user ... I will try using the sys id to see if that works
**UPDATE**
I changed the script to use the sys_id to populate the caller_name field and it now works!
I spent a while trying to figure this out and now that I see what the issue was I feel a little foolish.
Thank you so much for your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2015 01:06 AM
I am glad I could help.
The value of a reference field is always the sys_id of the record it points to. Just in case, detailed information about reference fields is available in the production documentation:
Reference Fields - ServiceNow Wiki
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/