- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 10:33 AM
I want to import beneficiary data to the employee document table so I have created a data source and transform map
I have written the Source script for the beneficiay feild (reference field)
answer = (function transformEntry(source) {
// Add your code here
var name = new GlideRecord("sn_hr_core_beneficiary");
name.addQuery("beneficiary_name",source.u_beneficiary_name);
name.addQuery("employee",source.u_employee_name);
name.query();
if(name.next())
{
var id= current.sys_id;
}
return id;
// return the value to be put into the target field
})(source);
When I import the beneficiary data it is not getting imported in the employee document table and getting this Message log : "Reference field value for sn_hr_ef_employee_document.u_beneficiary rejected: undefined"
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 03:06 AM
Hi,
the target field which you are setting is reference to "sn_hr_core_beneficiary" right?
then you need to return that record sysId
Also employee field on "sn_hr_core_beneficiary" is reference to sys_user so you need to dot walk to name since you are getting name in your excel
answer = (function transformEntry(source) {
// Add your code here
var id;
var name = new GlideRecord("sn_hr_core_beneficiary");
name.addQuery("beneficiary_name",source.u_beneficiary_name);
name.addQuery("employee.name",source.u_employee_name);
name.query();
if(name.next())
{
id = name.getUniqueValue();
}
return id;
// return the value to be put into the target field
})(source);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 10:39 AM
Hi @Priya
Declare variable outside if:
var id = '';
var name = new GlideRecord("sn_hr_core_beneficiary");
name.addQuery("beneficiary_name",source.u_beneficiary_name);
name.addQuery("employee",source.u_employee_name);
name.query();
if(name.next()){
id= current.sys_id;
}
return id;
Feel free to mark correct, if your issue has been resolved, so it ends up in solved queue.
Will be helpful for others looking for the similar query.
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 11:01 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 11:29 AM
You have to share details about the transform map, which is going to be a completely different thing.
Go to your import set and check Import set rows related list to check why the records were ignored
If I have answered your original query, mark the answer as helpful and correct
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 01:27 AM