Coalesce in transform but update multiple records

johnfw
Kilo Expert

Hi Community,

I have a data source that includes all of the 'titles' of the software installation table records.

I need to use that datasource to flag \software installations. Target table is cmdb_sam_sw_install

I have the transform script and map sort of working, but need to coalesce on the display name and version to ensure I don't create records and only update existing ones. 

Does anyone know a way to update all records with the same display label but still coalesce ?

Example (not real):

The source database tells me the flagged category (custom field) of any software installation called "Chrome" should be 1 if the version is < 9

There are 200 computers with Chrome 8

How can I update all of those 200 records whilst still coalescing on version and display label  - default behaviour is to update just 1 of the records.

Is it possible, for example, to pull all the sys_ids for the matching records and dynamically add them to the transform map, and then coalesce on sys_id ?

Thanks in advance for any assistance,

John

 

 

 

4 REPLIES 4

Harish Murikina
Tera Guru

Hi John,

It sounds weird, but you can do it using onbefore transform script.

var category = source.getValue("u_category/whatver your source field name");

var gr = new GlideRecord("table name which ever records you would like to update");

gr.addQuery("give dictionary name which ever you would like to compare",category);

gr.query();

while (gr.next()) {

gr.fieldd1 = value1/source.getValue("value1 field name");//In case if you want to update values from the sheet.

gr.field2

.

.

like wise goes on which ever fields you would like to update

gr.update();

}

Hi,

Thanks for the answer. Do you mean a transform script or a field mapping script. 

If a transform script, the TransformRow function needs to be called doesn't it ?

John

 

Hi,

Yes transform script not field mapping script.

You can use the above code it will work nothing else to do.

Regards,

Harish Murikinati. 

Mukesh Sharma
Giga Expert

Hi John , 

 

Based on your logic you might also need to use ignore=true in your transform script . It will prevent unnecessary records to create or update . 

 

 

Thanks

Mukesh Sharma