I am trying auto populate user location on load of a record producer . using this script but it is not populating
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2022 02:43 AM
I am using this script for the same :
function onLoad() {
var id = g_form.getValue('caller_id');
var user = new GlideRecord('sys_user');
user.addQuery('sys_id', id);
user.query();
if (user.next()) {
g_form.setValue('location', user.location);
}
}
Also trying to change the location is caller is changed in the same record producer and using this script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == '' || newValue == null) {
g_form.setValue('location', '');
return;
}
if (!g_form.hasField('location'))
return;
var caller = g_form.getReference('caller_id', setLocation);
}
function setLocation(caller) {
if (caller)
g_form.setValue('location', caller.location);
}
both are not working. could anyone suggest why?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2022 03:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2022 03:03 AM
I am trying on record producer. Thus it is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2022 06:39 AM
It's a record producer and not form
So dot walking and adding fields will not work.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader