how to update multiple records in target table from one record in source table in a transform map?

ashwanikumar
Tera Expert

Hi All,

i have multiple records in a target table with the same user ID. As per the requirement i want to update all the records in target table using one source record.

i am using an excel with data for 5 fields. rest of the column data will remain same.

how can i achieve this?


Thanks,

KUMAR

12 REPLIES 12

Priya Shekar
Giga Guru

Hi Ashwani,



You should be writing condition in the transform script where it should get the source record userid.


And get all the records in target table with that particular userid and update.


tsylte
Tera Contributor

Did you find a solution to this? I have the same situation, wondering what is the best way to accomplish this.

Hello,

 

I make it work today but writing an 'onAfter' script in 'Transform Map'. I am providing a sample script as below - 

Scenario - adding comments aginst the user based on each department who are eligible for promotion.

Code

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

var gr = new GlideRecord('sys_user');
var dep = source.u_user_department;
gr.addQuery('department', dep);
gr.setValue('comments', 'eligible for promotion');
gr.updateMultiple();

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

 

Please mark it 'helpful' if it really helps you.......thanks.

 

 

mikeearnheart
Kilo Contributor

Sorry to bring up an old thread.

Can someone elaborate on this solution please?  An example would be beneficial.

I am attempting to use the import/transform solution to find all location records with a given key value and set the 'IsDeleted' value = 'true'.

Thanks,

Mike