Field Map - Source Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2012 07:45 PM
I have one of the field as reference in target table.I need to import the values from the excel file,which contains the value of the field.So i used the field map source script to fetch the sys id of it & thereby to set the value in reference field of the target table.The script is working fine when i try in Script Background but its not in Source script of the field Map.Following is the script part:
var impact=source.fieldname;
var imp_ci=new GlideRecord('table name');
imp_ci.addQuery('name',impact);
imp_ci.query();
if(imp_ci.next()){
answer=imp_ci.sys_id;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2012 06:15 AM
You don't even need to do a source script on the field map - you can utilize the Referenced value field name field that is displayed when you are transforming to a reference field (see attachment). In your case the value in that field should be
.
name
You can also find more about the "Referenced value field name" field on this wiki article - http://wiki.service-now.com/index.php?title=Creating_New_Transform_Maps#Creating_a_Field_Map

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2018 02:36 AM
an ancient topic but I was also looking for a solution on this,
the issue is that I have in the import table a host name but I do need a sys_id, so I have to mach the host name from import table with the host name on SNOW and insert into the destination table the sys_id ..
(in this case the external_unique_Id values are not in sync)
the solution is to add the field maps and run a script on the transform map ( not a transform script )
(function transformRow(source, target, map, log, isUpdate) {
var srv=new GlideRecord('cmdb_ci_server');
srv.addQuery('name',source.u_hostname);
srv.query();
if(srv.next()){ // in this case we take just the first match, should be done by Unique_ID
target.u_server_sys_id=srv.sys_id;
}
})(source, target, map, log, action==="update");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2018 03:49 AM
Hi Ram,
If you know which column the value belongs to you can directly give in referenced value field name no need for field map script.
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
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
‎06-01-2022 05:28 AM
Hi Ankur,
I am receiving the display value in my source field. How do I set the sys_id value in the target field?