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-25-2021 09:32 PM
Hi,
you should wrap both the lines within the if condition
var str='';
if(producer.audience_for_assignment!=''){
str=str+''+ producer.additional_details_requirements;
current.description = str;
}
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
‎06-28-2021 10:35 AM
Thanks for you assistance but it's still not working. I'll keep trying to tweak it though. This is what I've got right now.
var str='';
if(producer.audience_for_assignment!=''){
str = str +''+ producer.audience_for_assignment;
if(producer.producer.additional_details_requirements!='')
str = str +''+ producer.additional_details_requirements;
current.description = str;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2021 10:13 PM
Hi,
try to add more gs.info() statements and check what's the issue
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
‎06-29-2020 06:08 AM
Hi
You may loop through the producer object -
for(var varObjItr in producer)
current.work_notes+=producer[varObjItr]+'\n';
EDIT:
Editing the comment, since looping the complete producer object might give other properties which are of no relevance.
Hence, please follow below solution -
var test = [];
for(var v in producer){
if (v.startsWith("IO")) { //only variables
var question = new GlideRecord('item_option_new');
question.get(v.substring(2)); // Querying by sys_id to determine question text
test += question.question_text + ": " + producer[v] + "\n"; // Set key:value pair to variable
}
}
current.work_notes = test; // Set Work Notes on new record
Reference:
Please mark the answer correct/ helpful, if it helps.
Regards,
Anirban
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2021 02:51 AM
Hello Anirban ,
is possible to have question and value in order wise?
like variable v1 have order 100 and variable v2 have order 200.
it should be come like v1 first and then v2
v1 : 121
v2 : 321
Thanks