Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2025 07:36 AM
Hi Beyza,
This sounds like 'conditional coalesce' which is a documented way to coalesce given a script. Updating records using coalesce
- Create a new field map
- Set the field mapping to 'use source script' , coalesce, and specify the target field as 'sys id'
- Set the script to identify the target record
answer = (function transformEntry(source) {
var Code = source.u_code;
var sourceDateDeleted = source.u_datedeleted;
var existing = new GlideRecord('u_cmdb_ci_xyz');
existing.addQuery('name', Code);
existing.addQuery('u_date_deleted', sourceDateDeleted);
existing.setLimit(1);
existing.query();
if(existing.next()){
return existing.getUniqueValue(); //Return the sys_id of the record to update
}
//return -1 which indicates we want to create a new record
return '-1';
})(source);