How to stop or reject a record to be created/inserted in Target Table using transform map when the value for that field does not exists in user or group Table?

Mishu
Tera Expert

How to stop or reject a record  to be created/inserted in Target Table using transform map when the value for that field already exists in user or group Table?

Eg: If my excel column 'User' has a value say July then this value should be rejected and the record should not be inserted itself as there is no user with July Name in the user table.

I tried using Choice action = reject for group and user field but its still allowing all the values to be inserted and not rejecting it .

 

How to fix this ?

 

3 REPLIES 3

Shubham Tipnis
Kilo Sage
Kilo Sage

Hi Mishu,

Try using ignore = true; in the script where you want to reject the data insertion.

Please mark correct/helpful if applicable.

Regards,

Shubham

 

 

Regards,
Shubham Tipnis
 ServiceNow Enthusiast
️ 3x Rising Star (2022–2024) – ServiceNow Community
 Sharing insights, use cases & real-world learnings from the Now Platform
 Always learning. Always building.

Harish KM
Kilo Patron
Kilo Patron

HI for this scenario use Coalesce on User field and Group field . Incase if other fields needs to be updated. It will update the record else it will skip also you can avoid duplicates.

Read below doc

https://docs.servicenow.com/en-US/bundle/sandiego-platform-administration/page/administer/import-sets/concept/c_ImportSetCoalesce.html

Regards
Harish

I just tried with Choice Action = ignore and wrote 2 transform script :

1. on before 

if (action == 'insert') { 

   ignore = true;

 

2. On After which throws an error in logs

 var userName = source.u_assigned_to;

 var gr = new GlideRecord("sys_user");
 gr.addQuery("user_name", userName);
 gr.setLimit(1);
 gr.query();

 if (gr.next()) {
    return gr.user_name;
 } 
 else{
    log.error('There is no user available with USER ID ' + source.u_assigned_to);
 }

Its working for me ..