Field Map Not Working Properly

Ariomar de Deus
Tera Contributor

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?

1 ACCEPTED SOLUTION

Voona Rohila
Kilo Patron
Kilo Patron

Hi @Ariomar de Deus 

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

View solution in original post

1 REPLY 1

Voona Rohila
Kilo Patron
Kilo Patron

Hi @Ariomar de Deus 

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