- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2017 08:25 PM
Hi All,
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:
=============
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 01:34 AM
Hi Ravishankar,
Please find below code. this is help full for you.
var emp = source.u_cilocation;
var gr = new GlideRecord("table name");
gr.addQuery("location field name", emp);
gr.query();
if (gr.next()) {
var reqRecord = current..getRefRecord();
reqRecord.target.location = gr.sys_id;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2017 11:56 PM
Hi Srivastava,
I need to have 'name' field display value field to be set to target.location .
Please suggest
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 12:14 AM
Hi Ravishankar,
Please find below code. this is help full for you.
var emp = source.u_cilocation;
var gr = new GlideRecord("table name");
gr.addQuery("location field name", emp);
gr.query();
if (gr.next()) {
var reqRecord = current..getRefRecord();
reqRecord.target.location = gr.sys_id;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2017 11:59 PM
Hi Srivastava,
Please let me know if the below code will help to have 'name' field display value field to be set to target.location .
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var sloc = source.u_cilocation;
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");
target.location = loc.getUniqueValue();
gs.log("TagetLOC :"+target.location);
}
})(source, map, log, target);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 12:53 AM
I think the location field on target table (cmdb_ci) is a reference field? it should work, please test let us know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2017 12:57 AM
Hi ,
I have tried that target.location = loc.getUniqueValue(); . Please suggest
But the Location is not populating when I ran the transform for single record.
However in logs it shows
TagetLOC :328 Xinghu Road,SuZhou