Dynamic Coalesce field in the Transform Maps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2021 07:32 AM
Hi Team,
Is there any way to set the "Coalesce" field to true based on the source value in the transform maps? Dynamically setting the "Coalesce" field to true or false based on the value received in the source field. Please provide your support as soon as possible.
Regards
Rahul

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2021 08:50 AM
So, for sepecific email ID you want to insert record irrespective of whether it is present already or not.
Can you tell me the target table?
Thank you,
Palani
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2021 08:51 AM
user table

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2021 09:21 AM
Then, I can think of only one option. But it is a kind of ugly.
Create a custom field in user table of type string and default value 1
In transform map, create a field map to this field with following details
User source script - Checked
Coalesce - Checked
Source script below
answer = (function transformEntry(source) {
// Add your code here
if (source.u_email_id == "your email id") {
return gs.print(Math.random().toString());
} else {
return "1";
}
})(source);
This will create a random number for the email id you mention in the script. So coalesce will be ignored and new record is inserted always. For other emails, since default is 1 and this function return 1, you will have the coalesce effective
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2021 08:23 AM
you cannot have the coalesce field as dynamic.
For example:
1) for 1st row you want email as coalesce
2) for 2nd row you want email + user name as coalesce
This won't happen if you configure field maps.
For your scenario you can use onBefore transform script which would give you flexibility to query target table with whatever field you want based on the source field for every row
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2021 08:39 AM
Hi Ankur,
Thanks for the reply. Is there any possibility or OOB method to set the "Coalesce" field to true or false dynamically based on the source script value?