How to update records in target table using transform map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2023 09:19 PM - edited 06-07-2023 09:23 PM
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";
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2023 09:47 PM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2023 09:55 PM - edited 06-07-2023 10:04 PM
This is ignoring the records where 2 duplicate name is present . it is not even updating the active records.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2023 10:03 PM
how can there be 2 names in target if you are marking coalesce on name field?
it should not
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2023 10:19 PM - edited 06-07-2023 10:19 PM
There are duplicate records, one is active one is inactive, i want to only update active one.