How to update records in target table using transform map

Priya75
Tera Contributor

Hi All,

 

I want to update records , I am using coalesce on name field but i want to update only active records in target table.

how can i achieve that. I am using  before transform script ,but it is not updating the records where active is true and name field has a duplicate(one as active=false).

 

 

if(action == "insert"){
ignore = true;
}

if(action=="update" && target.active == true){
action="update";

}

 

 

17 REPLIES 17

Ankur Bawiskar
Tera Patron
Tera Patron

@Priya75 

do this

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

	// Add your code here
	if(action == "insert"){
		ignore = true;
	}
	if(action == "update" && target.active.toString() == 'false'){
		ignore = true;
	}

})(source, map, log, target);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

This is ignoring the records where 2 duplicate name is present . it is not even updating the active records.

 

 

@Priya75 

how can there be 2 names in target if you are marking coalesce on name field?

it should not

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

There are duplicate records, one is active one is inactive, i want to only update active one.