- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-23-2022 10:16 PM
Hello Experts,
I have been trying to populate reference field value using transform map script, but it is not giving me exact output.
Could anyone suggest me any changes in the script so that field will take correct cafe value, Any suggestions much appreciated!
Thank you in advance,
Ujjwala
I am using below script in the run script section
/**
* For variables go to: http://wiki.service-now.com/index.php?title=Import_Sets_portal
**/
var cafe = new GlideRecord('u_tsc_restaurants');
cafe.addQuery('u_tsc_restaurant_number', source.u_store_name);
cafe.query();
if (cafe.next()) {
var sys_id = cafe.sys_id;
var gr = new GlideRecord('incident');
gr.initialize();
// target.u_tsc_restaurant = source.u_store_name;
target.short_description = " Test Tickets";
target.category = "Online";
target.u_tsc_type = "Menu";
target.u_tsc_subclassification = "Enable";
target.assignment_group = " ";
target.contact_type = "email";
// gr.insert();
}
I have written field map script also, still it is not working
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-23-2022 11:07 PM
Hi ujjwala,
Try to write your script as below under run script and it should insert a record in Incident table.
var cafe = new GlideRecord('u_tsc_restaurants');
cafe.addQuery('u_tsc_restaurant_number', source.u_store_name);
cafe.query();
if (cafe.next()) {
var sys_id = cafe.sys_id;
var gr = new GlideRecord('incident');
gr.initialize();
// target.u_tsc_restaurant = source.u_store_name;
gr.u_cafe = sys_id; // If you have reference field of Cafe on Incident table, add this line
gr.short_description = " Test Tickets";
gr.category = "Online";
gr.u_tsc_type = "Menu";
gr.u_tsc_subclassification = "Enable";
gr.assignment_group = " ";
gr.contact_type = "email";
gr.insert();
}
Please Mark ā
Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg
Regards
Sulabh Garg

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-23-2022 11:07 PM
Hi ujjwala,
Try to write your script as below under run script and it should insert a record in Incident table.
var cafe = new GlideRecord('u_tsc_restaurants');
cafe.addQuery('u_tsc_restaurant_number', source.u_store_name);
cafe.query();
if (cafe.next()) {
var sys_id = cafe.sys_id;
var gr = new GlideRecord('incident');
gr.initialize();
// target.u_tsc_restaurant = source.u_store_name;
gr.u_cafe = sys_id; // If you have reference field of Cafe on Incident table, add this line
gr.short_description = " Test Tickets";
gr.category = "Online";
gr.u_tsc_type = "Menu";
gr.u_tsc_subclassification = "Enable";
gr.assignment_group = " ";
gr.contact_type = "email";
gr.insert();
}
Please Mark ā
Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg
Regards
Sulabh Garg