- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2016 03:43 PM
Hi,
I'm trying to pass over Catalog Variables from a Record Producer to show in the 'Notes' in the Incident.
Just like these posts https://community.servicenow.com/thread/156305 and https://community.servicenow.com/thread/149636
I've added the below script in the Record Producer script section and get syntax error of: WARNING at line 2: Bad for in variable 'key'.
var wn = 'Variables:';
for (key in current.variables) {
var v = current.variables[key];
wn += '\n' + v.getGlideObject().getQuestion().getLabel() + ':' + v.getDisplayValue();
}
current.work_notes = wn;
When I run the form, it only displays in notes
'Variables:'
One of the form Variable Name is: onboard_name and another is onboard_job.
Knowing that straight copying online scripts to try suit my requirements won't always work, are you able to point me in the right direction to customize it to what I am attempting to do?
I need to display Catalog Variables in a record producer to appear in the 'Note' Section of an Incident as if they were on the form.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2016 11:26 PM
Hi Tony,
You can also use:
var wn = 'Variables:';
for (var key in producer)
if (producer[key]) {
if (key.search('onboard') != -1) {
wn += '\n' + key + ':' + producer[key];
}
}
current.work_notes = wn;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2016 02:16 PM
Hi Tony,
If that solved your problem, please mark any of the answer correct and close the thread. That might also help other people facing the same problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2016 09:16 PM
Hi Deepak,
Is there a way to convert the sys_id to the value names for the fields,
I have reference fields I am trying to call using the code above, and when it pulls the data through, it shows as a Sys_id and not the value they have selected from the reference.
EG. The reference variable is pulling from the Department Table, where the user can select a department, When the form is complete and pulled through to the notes, it displays as a sys_id and not the value they selected.
and where can I find all information in 'producer'?
var wn = 'Variables:';
for (var key in producer)
if (producer[key]) {
if (key.search('onboard') != -1) {
wn += '\n' + key + ':' + producer[key];
}
}
current.work_notes = wn;
much appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2016 02:54 AM
Hi Tony,
You can use:
var wn = 'Variables:';
for (var key in producer)
if (producer[key]) {
if (key.search('onboard') != -1) {
wn += '\n' + key + ':' + producer[key].getDisplayValue();
}
}
current.work_notes = wn;
