How to insert records on incident table using transform script ?

Ujjwala Wagh
Kilo Contributor

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

find_real_file.png

6 REPLIES 6

Musab Rasheed
Tera Sage
Tera Sage

Hello,

Check this article below

https://community.servicenow.com/community?id=community_blog&sys_id=908c26e1dbd0dbc01dcaf3231f9619c4

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

chetan17421
Tera Guru

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.

 

asifnoor
Kilo Patron

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.

https://community.servicenow.com/community?id=community_article&sys_id=0a9b3d5bdb86ffc04abd5583ca961...

Mark the comment as a correct answer and helpful if this has helped to solve the problem.

Hello @asifnoor ,

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");