How to Map variables of RITM Table to fields in INCIDENT in javascript

Priya1111
Tera Contributor

 

HI All,

Could you suggest javascript code to how to Map variables present in RITM  to fields in INCIDENT table.

 

Thanks

 

1 ACCEPTED SOLUTION

Hi,

script should work fine provided

1) the variable on RITM is correct and refers to cmn_department

2) you should insert() and not update

var rec = new GlideRecord('incident');
rec.initialize();
rec.department= current.variables.department;
rec.insert() ;

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

11 REPLIES 11

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can use workflow run script and sample script like this

var rec = new GlideRecord('incident');

rec.initialize();

rec.short_description = current.variables.variableName;

regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Priya1111
Tera Contributor

Hi,

Thanks for the reply, 

I have tried the above script in UI Action without workflow and it doesnot work.

I need the script for UI Action where the some variables in RITM must be mapped in Incident 

 

Thanks

Hi,

logic still remains the same

If your UI action is on RITM table then you can access variable value like this

current.variables.<variableName>

Ensure you map to correct field

For Example: Reference variable to user table can be mapped with caller_id of incident

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi,

I have tried in the same way by adding the script in one of the catalog item workflow

find_real_file.png

Unfortunately, Still the variable in ritm didnot map with the department.

I've attached the image too 

 

Thanks