How to update record based on multiple coalesce field

shaik_irfan
Tera Guru

Hi,

 

I have a import set and transform map where i am importing user record based on user id and email id i need to update record when both field values are matched and i made both fields as colease to true but still it is creating a new record.

 

Is there a way we can acheive this?

1 ACCEPTED SOLUTION

shloke04
Kilo Patron

HI @shaik.irfan 

What you can do here is write a On Before Transform Script and use the script shared below:

var getSourceUserID = source.FieldName.toString();//Replace "FieldName" with source User ID;
var getSourceemail = source.FieldName.toString();//Replace "FieldName" with source Email;

var gr = new GlideRecord('sys_user');
gr.addQuery('user_name',getSourceUserID);
gr.addQuery('email',getSourceemail);
gr.query();
if(gr.next()){
....do the update here for the fields you want as for example below:
gr.name = source.FieldName;
gr.update();
}else{
ignore=true;
}

This should work for you.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

6 REPLIES 6

shloke04
Kilo Patron

HI @shaik.irfan 

What you can do here is write a On Before Transform Script and use the script shared below:

var getSourceUserID = source.FieldName.toString();//Replace "FieldName" with source User ID;
var getSourceemail = source.FieldName.toString();//Replace "FieldName" with source Email;

var gr = new GlideRecord('sys_user');
gr.addQuery('user_name',getSourceUserID);
gr.addQuery('email',getSourceemail);
gr.query();
if(gr.next()){
....do the update here for the fields you want as for example below:
gr.name = source.FieldName;
gr.update();
}else{
ignore=true;
}

This should work for you.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

OlaN
Giga Sage
Giga Sage

Hi,

It should work like that if you mark both import fields as coalesce.
Can you share some images of your current transform setup?

 

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

should work fine.

Please share your field maps for this

Regards
Ankur

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

@shaik.irfan 

Can you share your existing field maps for this?

Ideally script is not required since you have made both the fields as Coalesce=true

So if both the values are found then it would updat

Even if 1 value is not present it would create

Regards
Ankur

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