How to write transform map script to check the contact's email is duplicate or not.

Chhavi Dixit
Tera Contributor

Hi Guys,

 

Need small help ....

How to write transform map script to check the contact's email is duplicate or not.

If duplicate email is found then ignore that record and populate a message that 'Duplicate email'.

 

Thanks!

Chhavi Agnihotri

1 ACCEPTED SOLUTION

@Chhavi Dixit This can be an event based onBefore transform script which will trigger before the transforming of every single row.

View solution in original post

4 REPLIES 4

Sandeep Rajput
Tera Patron
Tera Patron

@Chhavi Dixit Please check if the following script works for you.

 

// Check if the current email exists in the target table
var email = source.u_email; // Replace 'u_email' with the source field name for email
if (email) {
    // Query the target table (replace 'sys_user' with your target table if different)
    var contactGR = new GlideRecord('sys_user'); 
    contactGR.addQuery('email', email); // Replace 'email' with your target table's email field
    contactGR.query();

    if (contactGR.next()) {
        // Duplicate found, ignore the record
        ignore = true; // This will skip the current record
        gs.log("Duplicate email found: " + email + ". Skipping record.");
    }
}

@Sandeep Rajput , 

Thanks for quick response, could you please suggest me if this is explicit transform map script or event based transform map script.

 

Thanks!

Chhavi

@Chhavi Dixit This can be an event based onBefore transform script which will trigger before the transforming of every single row.

Thank you so much @Sandeep Rajput  🙂