Kieran Anson
Kilo Patron

Hi Beyza,

 

This sounds like 'conditional coalesce' which is a documented way to coalesce given a script. Updating records using coalesce 

 

  1. Create a new field map
  2. Set the field mapping to 'use source script' , coalesce, and specify the target field as 'sys id'
  3. 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);

View solution in original post