Dynamic Coalesce field in the Transform Maps

rahulrockkk
Tera Contributor

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

16 REPLIES 16

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

Thank you,
Palani

user table

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

Thank you,
Palani

Ankur Bawiskar
Tera Patron
Tera Patron

@rahulrockkk 

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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?