Using a single transform map, can I create records in different target tables?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2024 10:52 AM - edited 06-20-2024 11:02 AM
In an excel sheet like this
Short Description | Description | Category |
Create INC | XYZ | Software |
Create PRB | ABC | Hardware |
Create CHG | QQQ | Network |
Create INC | KKK | Network |
Create INC | MMM | Network |
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2024 04:31 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2024 09:28 PM
@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.