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

Hello ,

you need to insert the record but you are using update method which will not insert the record so try below

replace update with insert and it should work 

var rec = new GlideRecord('incident');

rec.initialize();

rec.department= current.variables.your_variable_name;

rec.insert() ;

HI,

Thanks for the reply, 

I have tried adding the below attachedto one of my Workflow items

find_real_file.png

Unfortunately, department variable if ritm is not mapped with incident field

Which type of filed is u_department on the RITM form ?and which type on incident form ?

1)make sure back end names from both the tables are correct 

also replace with this line 

rec.department= current.variables.u_department.toString();

In RITM ,Department is Reference Variable taken from cmn_department table.

In incident it is Field with same table.

also is the record getting inserted?

then is should map can you post your full UI action script please ?