Mapping field from record producer to another table via Script Include

Komaldeep
Tera Contributor

Hello Everyone,

Thank you in advance for the help.

I have the scenario for mapping 2 fields from the record producer variable to another table in the backend.

I have used this script in record producer scripting part - 

new sn_hr_core.script().funcname(producer.u_position_number,producer.eff);

and this code in the script include but not able to map the field - 

 ProjectDetailsCreation: function(pos,eff) {

var position = pos;

var effective = eff;

  var projDetail = new GlideRecord('tablename');

projDetail.initialize();

projDetail.u_position = position;

projDetail.u_eff = effective;

projDetail.insert();
            },

 

Can you suggest me the right solution?

 

1 ACCEPTED SOLUTION

AnubhavRitolia
Mega Sage
Mega Sage

Hi Komaldeep,

I don't think Script Include is required.

You can directly GlideRecord your table in Record Producer script:

var projDetail = new GlideRecord('tablename');

projDetail.initialize();

projDetail.u_position = producer.u_position_number;

projDetail.u_eff = producer.eff;

projDetail.insert();

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

View solution in original post

5 REPLIES 5

AnubhavRitolia
Mega Sage
Mega Sage

Hi Komaldeep,

I don't think Script Include is required.

You can directly GlideRecord your table in Record Producer script:

var projDetail = new GlideRecord('tablename');

projDetail.initialize();

projDetail.u_position = producer.u_position_number;

projDetail.u_eff = producer.eff;

projDetail.insert();

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

Hello 

I tried this solution, but it's not fulfilling the requirement (mapping is not taking place)

Thanks for your reply

Hi Komaldeep,

 

Can you please share the script you wrote and what error or issue you are facing after this?

Is your variable names are correct and what is variable type of both variables and fields?

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

Hello Anubhav, In the table position no is reference type and eff is date and time type. And in record producer also the fields are of same type.