How to map a field from a record producer using scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2020 03:58 AM
Hi i need help with a catalog client script. i'm trying to pass a value from the record producer to the incident based on value selected by the user. I understand we cannot use current to refer to the incident form,
if ((producer.team)== 'MAC'){
g_form.setValue('assignment_group','MAC-Support');}
i need this value to be mapped to the field in incident. But this is not working.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2020 05:41 AM
Hi,
this you need to add in record producer script which is server side
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2020 06:29 AM
ok i added that but it is not working in my case.
the if statement is not working, i had tried adding anther statement also earlier.
Is there anything that i might be missing?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2020 07:24 AM
Hi Dhanya,
what type of variable is team? is it string?
Is MAC-Support correct group name?
Can you share the updated script again?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2020 04:02 AM
Hi,
If this is a catalogue client script, I presume you're using an onChange script? change to the below:
Type: onChange
VariableName: team
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if (newValue == 'MAC') {
g_form.setValue('assignment_group', 'sysid_of_assignment_group');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2020 04:05 AM
Do add the display value as well. Only providing the sys_id on reference type fields/variables in a client script causes an additional database query to be made (= performance loss).
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field