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?
This content was last updated in 2022. It may still be useful, but could contain outdated information. Please confirm its accuracy before relying on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2022 10:03 PM
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 ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2022 10:09 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2022 10:19 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2022 10:29 PM
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 ..