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 10:18 PM
As per my understanding I don't think so.
If you use onBefore transform script you can use any field as coalesce during the query and would give you the flexibility going forward for code maintenance.
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-21-2021 12:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2021 02:32 AM
Example
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var incomingValue = source.u_myField;
var incomingFieldA = source.u_fieldA;
var incomingFieldB = source.u_fieldB;
var gr = new GlideRecord('target table');
if(incomingValue == 'Hello'){
gr.addQuery("fieldA", incomingFieldA);
}
else if(incomingValue == "BYE"){
gr.addQuery("fieldB", incomingFieldB);
}
gr.query();
if(gr.next()){
// record found now map and update
gr.fieldc = source.u_fieldC;
ignore = true;
}
})(source, map, log, target);
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
10-13-2022 12:48 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please close the thread by marking appropriate response as correct 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
07-20-2021 08:56 AM
Hello,
As per my knowledge, we cannot dynamically change the "Coalesce" value in field maps. to be honest we should not do configuration changes dynamically based on data. I would recommend writing your logic in the Transform scripts or the "Script' field on the Transform map record.
you have to explicitly write the logic for insert and update operations. Import set data can be accessed using "source". at the end of the script have "ignore=true" so duplicates will not be created.