How to identify the coalesce fields updating it via transform map?

Roxana4
Tera Contributor

I have a data source and transform map to update records in cmdb_ci_appl table. I need to update primary and secondary sites of some applicationn, We have coalesce on "name" and "application_id" fields to identify the records in target table. However, we have more than 1 record with same name and application_id in target table. So transform map is updating the first identified record. We need to put a validation in place so that correct record will be identified and updated by the transform map. The validation is like, if the sys_class_name ==  cmdb_ci_appl (this field is not in the map) then only update. Please note that our data source has only 4 fields in it, application_id name, primary site and secondary site, Any ideas on how this can be achieved? Thank you. 

10 REPLIES 10

Okay, then can you try with the OnBefore event script on transform map and check for the application_id and name fields with the class as cmdb_ci_appl.

 

Try the below code.

var gr = new GlideRecord('cmdb_ci_appl');
if (gr.get('Application_ID_FIELD=' + source.application_id + 'NAME_FIELD+' + name)) {
    //If there is a record with same ID and Name then update it.
} else {
    //Insert new record
}

 

Mark this as Helpful/Correct if Applicable.

Regards,

Sourabh