Issue with Catalog Client Script to set location
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 07:08 AM
Hi All,
I have an issue with my Catalog Client Script related to set the location in Single Line Text variable based on user's location from another variable ('requested_for')
Currently it looks like:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var affectedUser = g_form.getReference('requested_for', doAlert);
function doAlert(affectedUser) {
if (affectedUser) {
g_form.setValue('requested_for_location', affectedUser.location);
}
}
}
and it was working fine my 'requested_for_location' field was a Reference field not a SIngle Line Text field.
When it is a Single Line Text filed then it gives me a sys_id value,,
Do you know how can I chnage the script to receive 'normal' string value in this Single Line Text field?
Thanks in advance for help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 07:56 AM
Thanks for informing
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 07:32 AM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var affectedUser = g_form.getReference('requested_for', doAlert);
function doAlert(affectedUser) {
if (affectedUser) {
var location = affectedUser.location.getDisplayValue();
g_form.setValue('requested_for_location', location);
}
}
}