How to insert records on incident table using transform script ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2022 04:20 AM
Hello All,
I have been trying to load data into the system via inbound email attachment, but on transform incident table is not creating records, could anyone guide me for this ? Should I create transform script for this, if yes please suggest me the approach.
Thank you in advance!
Regards,
Ujjwala

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2022 04:36 AM
Hello,
Check this article below
https://community.servicenow.com/community?id=community_blog&sys_id=908c26e1dbd0dbc01dcaf3231f9619c4
Regards
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2022 04:39 AM
Hi,
You can write the script to create incidents in the after transform map script. This will create incident after each row is transformed into the target table.
Let me know if my answer helped you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2022 07:36 AM
Hi,
If you are using import sets, then yes there should be transform to create incident. Refer to this link to create transform map using import sets.
Mark the comment as a correct answer and helpful if this has helped to solve the problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2022 12:38 AM
Hello
As per your suggestion, I tried onAfter transform script and I am using below script:
Still, records are not getting created. Could you please correct me here ?
(function runTransformScript(source, map, log, target, isInsert /*undefined onStart*/ ) {
//var cafe = source.u_store_name;
var gr = new GlideRecord('u_tsc_restaurants');
gr.addQuery("u_tsc_restaurant_number", source.u_store_name);
gr.query();
if (gr.next()) {
target.u_tsc_restaurant = gr.sys_id;
// target.u_tsc_restaurant = source.u_store_name;
target.short_description = "Proactive: ";
target.category = "Online Ordering";
target.u_tsc_type = "(Online)";
target.u_tsc_subclassification = "Enable";
target.assignment_group = "7f61abf7db34e3802dfc78a6ae961997 ";
}
})(source, map, log, target, action == "insert");