Using a single transform map, can I create records in different target tables?

Suggy
Giga Sage
Is conditional Target Class based on a source column possible in a Transform map?
 

In an excel sheet like this

Short DescriptionDescriptionCategory
Create INCXYZSoftware
Create PRBABCHardware
Create CHGQQQNetwork
Create INCKKKNetwork
Create INCMMMNetwork

Based on the short description, if it contains the keyword 'INC', the record should get created in incident table. If it contains the keywork 'PRB' the record should get created in Problem table, likewise 'CHG' in Change request table.

 

All this should happen in a single Transform map. Is it possible?

6 REPLIES 6

Community Alums
Not applicable

Hi @Suggy ,

 

I think you should be able to do it by having a transform script.

below is the snippet of the same-

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
    var shortDes = source.u_short_description.toLowerCase();
    var incGr, chgGr;
    if (shortDes.includes('inc')) {
        incGr = new GlideRecord('incident');
        incGr.initialize();
        incGr.short_description = source.u_short_description;
        incGr.description = source.u_description;
        incGr.category = source.u_category;
        incGr.insert();
    } else if (shortDes.includes('chg')) {
        chgGr = new GlideRecord('change_request');
        chgGr.initialize();
        chgGr.short_description = source.u_short_description;
        chgGr.description = source.u_description;
        chgGr.category = source.u_category;
        chgGr.insert();
    }    
})(source, map, log, target);

 

Also please refer to the link shared by Mark.

 

If my response has resolved your query, please consider giving it a thumbs up ‌‌ and marking it as the correct answer‌‌!

 

Thanks & Regards,

Sanjay Kumar

@Community Alums That will work partially. ie if short description includes 'chg', based in the script it will create the record in CHG table also, and also its creating in INC table as well.