- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 12:11 AM
Hi All,
Sorry, I had to post this again as I did not get my issue resolved. Please help me with below.
Can someone please help with the below Transform script . I am trying to set the Location (location) field in cmdb_ci which is target table in Transform script.
The script is working fine when I checked in Logs , and also background script .When I checked the logs it returns the display value of name , please see below screenshot.
When I check it Location field in cmdb_ci after Transform, it is blank. not showing any value.
Transform Script:
==============
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var sloc = source.u_cilocation.toString();
var loc = new GlideRecord('cmn_location');
loc.addQuery('u_description',sloc);
loc.query();
gs.log("Location: "+loc.getEncodedQuery());
if(loc.next()){
gs.log("IF STATEMENT");
//var dnm = loc.getDisplayValue('name');
//target.location = loc.getDisplayValue('name');
target.location = loc.name;
gs.log("TagetLOC :"+target.location);
}
})(source, map, log, target);
Log screenshot: I want the below displayed valed of 'name' in my target 'location' field.
=============
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 12:51 AM
Hi Ravi
It should because the location field is a reference field.
The name of the location will be shown automatically if on the target table is set as display field.
If you are importing using an excel my suggestion is to test simply with just one record and see what happens
Cheers
R0b0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 12:37 AM
Hi Ravi
Not sure if this will help but i would suggest to use the sys_id instead of the name.
ps Is the script you are using a 'before' script right ?
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var sloc = source.u_cilocation.toString();
var loc = new GlideRecord('cmn_location');
loc.addQuery('u_description',sloc);
loc.query();
gs.log("Location: "+loc.getEncodedQuery());
if(loc.next()){
gs.log("IF STATEMENT");
//var dnm = loc.getDisplayValue('name');
//target.location = loc.getDisplayValue('name');
target.location = loc.sys_id;
gs.log("TagetLOC :"+target.location);
}
})(source, map, log, target);
Cheers
R0b0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 12:47 AM
Hi ,
Please let me know if putting target.location = loc.sys_id; will assign the 'name' field in cmn_location display value to 'lolcation' in Taget table ?
Yes I am using Onbefore Transform script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 12:51 AM
Hi Ravi
It should because the location field is a reference field.
The name of the location will be shown automatically if on the target table is set as display field.
If you are importing using an excel my suggestion is to test simply with just one record and see what happens
Cheers
R0b0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 01:02 AM