Reference field map failed in transform map.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2024 11:05 PM
I have wrote this code for checking the value in target table is it present or not .but its only check the first condition and rest of showing me error message
when i put the correct record for insert it ignore the record
var approverName = source.getValue('u_approver');
if (action == 'insert' && JSUtil.notNil(source.u_approver)) {
var gr = new GlideRecord('u_epi_approvers');
gr.addQuery('u_name',source.u_approver);
gr.query();
if (!gr.next()) {
ignore = true;
log.error('approver'+''+ approverName+' '+'is not found ');
}
}
//log.error('approver'+''+ approverName+' '+'is not found ');
var type1 = source.getValue('u_type');
if (action == 'insert' && JSUtil.notNil(source.u_type)) {
var Gr = new GlideRecord('u_choice_1');
Gr.addQuery('u_type',source.u_type);
Gr.query();
if (!Gr.next()) {
ignore = true;
log.error('type '+' '+type1 +' '+'is not found ');
}
}
})(source, map, log, target);
thanks
jyoti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2024 11:23 PM - edited 01-07-2024 11:24 PM
are you sure you are using correct field to query against?
u_name in table is queried against u_approver, Is that correct?
Also notice your row can be ignored if source type is not present in that choice table.
So please ensure if you are giving correct name of approver if it's entering the IF for type not found, if it is entering then it's ignoring because of that.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2024 11:55 PM
Yes im sure can you please help me on how to put multiple reference field in one transorm map script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 12:48 AM
Hi Jyoti,
I believe your script is currently checking both conditions individually. If any of these conditions are failing i.e. either it isn't getting a record with the correct approver or it isn't getting a record with the correct type, it is failing.
If you want to validate one row against both checks, try using a nested if condition or and AND condition. I believe that should work.
Also, if you're always getting the first error, I think you're checking the approver's name from your source table with the reference field in your target table. Could you check the type of fields that you're comparing. Maybe that helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 04:42 AM
can you please provide the code