COALESCE fields in transform maps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
So I have a requirement where in the sheet there multiple columns I am taking 3 columns here for that I need Help
1. name
2. site ID
3. company
In transform map I have selected COALESCE true for site ID and company field this is check at the start if both are matched for other record exisiting it would update it
But other than that after if site ID and company field is not matched we want to check name and company field if both are matched then also the exisiting record should be updated? how can I add this logic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I have tried this but its not even inserting records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I think the issue is related with the company ID. the source.sys_import_set.short_description returns empty. if the company id is a value in the document, I think you are getting it in the wrong way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @indrajeetma
You can’t set two coalesce combinations in one transform map, but you can handle it with an onBefore Transform Script.
Try this:
(function transformEntry(source, target, map, log, isUpdate) {
// Check Site ID + Company first
var rec = new GlideRecord('your_target_table');
rec.addQuery('site_id', source.u_site_id);
rec.addQuery('company', source.u_company);
rec.query();
if (!rec.next()) {
// If not found, check Name + Company
var alt = new GlideRecord('your_target_table');
alt.addQuery('name', source.u_name);
alt.addQuery('company', source.u_company);
alt.query();
if (alt.next())
target.sys_id = alt.sys_id; // Update existing record
}
})();
This lets the import first match on Site ID + Company, and if not found, it falls back to Name + Company before inserting a new record.