The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Record producer data to Incident description

tcorniels
Tera Contributor

I have created a record producer that will gather some information and create an incident.   I have then created a template to fill out some of the standard incident fields.   What I am having a problem with is that once the user completes the form the incident will be created but none of the information they entered appears anywhere.   Ultimately I would like all of their entered field information to appear in the description field of the created incident but can't figure out how to get that to happen.

10 REPLIES 10

Michael Fry1
Kilo Patron

In the script field of the record producer, you can add something like: current.description = producer.variablename + ' , ' + producer.variablename2;


Do that for all your variables and the data entered should end up in the description field.


Hi Michael - is there a way to do this so that only the fields that are entered show - similar to the email script attached that shows only the variables that were selected?



Cheers


ghsrikanth
Tera Guru

The template will work fine, please post the template that you have created


The variables in the record producer can be accessed by producer.variable



Record Producer - ServiceNow Wiki


Wiki has an exclusive article to create incident through record producer -


Creating a Record Producer to Log Incidents - ServiceNow Wiki




Mark if it is helpful or correct, feedback is appreciated  


Thanks for that - I found the following in an article (unable to find it now) where I copied the following into the record producer script field and it worked0:



  1. var test = [];  
  2. for(var v in producer) {      
  3.   if (v.startsWith("IO")) {//only variables      
  4.       var question = new GlideRecord('item_option_new');          
  5.       question.get(v.substring(2)); // Querying by sys_id to determine question text          
  6.       test += question.question_text + ": " + producer[v] + "\n"; // Set key:value pair to variable      
  7.   }  
  8. }  
  9. current.work_notes = test; // Set Work Notes on new record


However, this shows all variables whether they were selected or not. What coding do I need to do to only show variables that have been selected.


I tried to add the following between line 3 and 4 but it did not help (this is from my email script that works)



  • if(v.get(i).getDisplayValue() != 'No' && v.get(i).getDisplayValue() != 'false' && v.get(i).getDisplayValue() != '' && v.get(i).getDisplayValue() != "-- None --"){


Any thoughts or suggestions would be appreciated


Cheers