Record producer fields mapping

DSV22
Tera Contributor

Hi team,

 

I have 3 fields in record producer to map with the 3 fields with incident form which I have done.using the script 

current.business_service = producer.field_name;

current.category= producer.field_name;

 

Category field is taking the backend choice value and the Business services field is not taking any value since it is a reference field in the incident form 

 

Can anyone please suggest how to achieve this task to populate the exact values which is selected while submitting the form.

 

Thanks

 

11 REPLIES 11

Danish Bhairag2
Tera Sage
Tera Sage

Hi @DSV22 ,

 

What are the types of field on your Record producer. Possible to share a snip would be great.

 

Thanks,

Danish

Hi @Danish Bhairag2,

 

These are RP variables

DSV22_0-1726050715655.png

I want to populate these in the category and services field in the incident form.

 

Hi @DSV22 ,

 

As i could see the type of both the fields are select box. Also as we know when its a reference field in servicenow it only accepts sys id to populate the record so in that case what u need to do is, in the producer script section before doing this 

 

current.business_service = producer.field_name;

 

we will 1st fetch the sys id of that application from the corresponding table.

 

 

var gr = new GlideRecord('cmdb_ci_service'); // Assuming this is the table mapped at your end as well on Inicident form
gr.addQuery('name',producer.application_affected);
gr.query();
if(gr.next()){
current.service = gr.sys_id; //u can replace with the backend field name from incident form (current.field_name)
}

 

 

for category u need to make sure whatever choices u have created under the field of Issue type the same choices are also available on the incident form category field. If its not present it will not map the display value it will map the Backend value. Also use below command to map the category value.

 

current.category = producer.issue_type.getDisplayValue();

 

Thanks,

Danish

 

 

Hi @Danish Bhairag2 ,

 

For the issue type it is working but for service field it is not working

 

var gr = new GlideRecord('cmdb_ci_service');
gr.addQuery('name',producer.application_affected);
gr.query();
if(gr.next()){
current.business_service == gr.sys_id; //replaced with the backend name of the field from incident form
}