How do I map all variables into the description field & activity log from a record producer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 04:20 AM
Good Afternoon!
I have created a new record producer for our "Log an incident form" - its quite complex and includes a few different ui policies (for example, if category is protection then show the the protection variable set) - currently i have all the new variables added to the form and the UI policies and actions working perfectly on the front end catalogue form, but on submission, none of the completed fields are been pulled through to the back end incident.
Can you please advise how i can get this working?
thank you very much ... just an example...
This is our front end form...
As you can see, nothing is mapped across to the back end...
I'm aware its something here that we have to amend...
can you please advise the following;
- what script i need to include all of the completed variables only into the incident record
- how i can amend this going forward if we include more variables sets within the incident record producer
- How i can map all completed variables into the activity log
Thank you
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 04:37 AM
Hi,
the usual way to pick value from record producer variable is below
current.work_notes = producer.<variableName>;
Sample Script
current.description = producer.description;
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
06-29-2020 04:46 AM
Am i able to map more than one variable to the same field on the back end?
For example,
can i map all of my protection variables on my screen shot to the description field on the back end?
If so, would it be written like this...
current.caller_id = gs.getUserID();
current.contact_type = "self-service";
current.assignment_group = "d003702ddbc70010372b9532ca961956"; // Service Desk
current.impact = "";
current.urgency = "";
current.priority = "";
current.description = producer.broker_number;
current.description = producer.user_id;
etc...
would this work and pull all the filled in variables accross?
do i need to write this line "current.description = producer.description;" for each of my variables that i have on the form. If so, should i be including an IF statement within the script, for example if relevant_category_for_incident is protection then map the following fields... etc... can you provide some further examples/advise? Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 06:17 AM
Hi,
yes you can by concatenating the values if the target field is string type
you cannot map multiple values to drop down, reference etc
var str = '';
if(producer.broker_number != '')
str = str + ' ' + producer.broker_number;
if(producer.user_id != '')
str = str + ' ' + producer.user_id;
current.description = str;
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
06-25-2021 02:59 PM
Ankur,
I am trying to do what you suggested but it's not working. I have two variables that I want to map to the Description field. I used your example and added the last four lines in the script on my record producer. Do you know what I've done wrong?
//current.hr_service = '9239dd32db5dcc90c811400e0b9619b2'; // Sys_id of Assign a course to employees service
current.hr_service = new sn_hr_core.hr_ServicesUtil().getServiceSysIdByProducerId(cat_item.sys_id); //Populate HR service
current.contact_type = 'self_service'; // Set contact type field
/* New change 09-09-2020 */
// current.opened_for = gs.getUserID();
// var id = producer.requested_for;
// current.subject_person = id;
//Uing Glide Record to get the VIP information of requested for user
var setPriority = new GlideRecord('sys_user');
setPriority.get(id);
if(setPriority .vip == true)
current.priority = 3; // Set priority to 3 - Moderate
else
current.priority = 4; // Set priority to 4 - Low
var str='';
if(producer.audience_for_assignment!='')
str=str+''+ producer.additional_details_requirements;
current.description = str;