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 10:22 PM
then it should update only the active record as per the onBefore transform script
Can you share your field maps?
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 11:14 PM - edited 06-07-2023 11:23 PM
field maps has only 2 fields , one is name is a string field and another field is internal/external(dropdown), so we are updating on the basis of name. i have used it earlier it updated all the records. but some of the active false record as well, so now i m trying to validate it before the insertion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2023 11:15 PM
as per onBefore transform script I shared it should update only the one which is active=true
did you add logs and check what's the value of target.active in onBefore transform script
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 11:53 PM
if(action == "update" && target.active.toString() == 'false'){ ignore = true; }
if i use this then it is not going inside the if condition, if i remove update part and only write target.active is true , then i am getting logs that target.active= false, where as i have 2 records present in the list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2023 11:56 PM
did you check what's the action when you print in logs?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader