- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 04:11 AM
Hey guys, I'm creating a field map with the code below, but there are a few issues that are causing the code to not work properly.
When I check Coalesce, all records are skipped and this error message appears:
"Unable to resolve target record, coalesce values not present:"
The other issue is that when I uncheck Coalesce, it inserts all records but doesn't insert existing records, creating new, empty records with new sys IDs.
(function transformEntry(source) {
if (source.u_cod_subitem) {
var a1 = new GlideRecord("x_bdb_5wa_000004_teste");
a1.addQuery("cd_sub_item", source.u_cod_subitem);
a1.query();
if (a1.next()) {
return a1.sys_id.toString();
}
}
return "";
})(source);
Could someone help me find a solution for this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 04:41 AM
We need more information of the transform map you configured to help you out on this issue
Is cd_sub_item a what type of field in x_bdb_5wa_000004_teste table and what value is coming from source.u_cod_subitem?
Also replace source.u_cod_subitem with source.u_cod_subitem.toString() and check.
(function transformEntry(source) {
if (source.u_cod_subitem) {
var a1 = new GlideRecord("x_bdb_5wa_000004_teste");
a1.addQuery("cd_sub_item", source.u_cod_subitem.toString());
a1.query();
if (a1.next()) {
return a1.sys_id.toString();
}
}
return "";
})(source);
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 04:41 AM
We need more information of the transform map you configured to help you out on this issue
Is cd_sub_item a what type of field in x_bdb_5wa_000004_teste table and what value is coming from source.u_cod_subitem?
Also replace source.u_cod_subitem with source.u_cod_subitem.toString() and check.
(function transformEntry(source) {
if (source.u_cod_subitem) {
var a1 = new GlideRecord("x_bdb_5wa_000004_teste");
a1.addQuery("cd_sub_item", source.u_cod_subitem.toString());
a1.query();
if (a1.next()) {
return a1.sys_id.toString();
}
}
return "";
})(source);
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP