- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2019 11:29 PM
I am doing data load to custom table where I have given 1 condition if the 'user_name' already exists in 'User' table for those records a message should be updated in Note field that "user exists". It is updating but blank records getting created along with records required during transform map and I haven't checked on copy empty fields.
I have written transform script for onBefore condition.
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var gr1 = new GlideRecord('sys_user');
gr1.addQuery('user_name', source.u_adid);
gr1.query();
while(gr1.next())
{
target.u_note = 'Existing user ' + source.u_adid ;
target.update();
log.info("User name exists again" + source.u_adid);
}
})(source, map, log, target);
Could someone help me with this issue??
Solved! Go to Solution.
- Labels:
-
Multiple Versions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2019 03:46 PM
Replace target.update() with ignore = true; Then give it a try. I don't think you need target.update().

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2019 03:46 PM
Replace target.update() with ignore = true; Then give it a try. I don't think you need target.update().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2019 05:55 AM
Hi Michael,
I removed target.update() and it is working fine. Can you explain why we should not use target.update()?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2019 11:39 AM
Hi Mit,
I'm not Micheal, or really even an expert on this. But if I had to guess it's because the transform map will update/insert the target record when the entire transform map is done. By including target.update() you are essentially telling the transform map to update/insert the target record before it is meant to do so. This is especially true because you are using an onBefore transform script, which is designed to make the changes before the target record is updated.