- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2017 08:06 PM
Hi All,
I am working on a Transform script to populate a reference field called model_id in the Target table(cmdb_ci).I am trying to Concatenate the "Manufacturer" and "Model" from my Custom Table and querying against the "short_description" in pc_vendor_cat_item with the Concatenated result.
As per logs I am able to see that I am getting the value , however it is not assigning to model_id in target field . It still shows as Unknown. Please see below what I found in logs and please guide.
Code:
====
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var mnfc = source.u_manufacturer.trim();
var mnfcr = mnfc.replace(/,/g, "");
var mdl = source.u_model.trim();
//var res = mnfcr.concat(mdl);
var res = mnfcr + " " + mdl;
gs.log("Concatenated string : "+res);
var type = source.u_ci_server_type;
if(type!='Virtual'){
var pm = new GlideRecord('pc_vendor_cat_item');
pm.addQuery('short_description',res);
pm.query();
gs.log("QueryResult :"+pm.getEncodedQuery());
if(pm.next()){
gs.log("into secondif"); ---- I am getting in here and able to see this logs.
var mdel = pm.getValue('short_description');
gs.log("ModelValue: "+mdel); ---- I am able to see this logs and coming correctly as ModelValue: HP ProLiant DL380 G7
target.model_id = mdel;
gs.log("Target :"+target.model_id); --- I am able to see the value correctly here also in logs as Target :HP ProLiant DL380 G7
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2017 08:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2017 08:35 PM
Hi Michael,
This did not work, I tried this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2017 08:40 PM
Check if this helps. What Michael told should work, otherwise try with this one also and again check what is the display value set for you model_id's table.
target.setDisplayValue('model_id', mdel);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2017 11:23 PM
Hi Ravi,
Is it working now?