Transform map script is not working on target field

Vamshi_ch123
Tera Contributor

Hi All,

 

I have written a script on transform map field mapping as below to get the displayname in return to update the Model ID field in CMDB 

here I'm trying to update the display value in target field but it's returning blank

Vamshi_ch123_0-1724832697134.png

 

my script: 

 

answer = (function transformEntry(source) {
   
    var gr = new GlideRecord("cmdb_model");  
   gr.addQuery('name', source.u_model);
   gr.addQuery('manufacturer.name', source.u_make);
  gr.query();


   var returnVal = '';


   if(gr.next()){  


       returnVal = gr.display_name;  


   }
   return returnVal;



})(source);
 
Thank you
3 REPLIES 3

Not applicable

Hi @Vamshi_ch123 ,

 

Have you tried logging source.u_model and source.u_make to see correct values from source??

and your choice action is "Create" , your logic says if record not found it return empty to create.

 

 

Hi @Community Alums ,

 

so can I keep the choice as ignore for blank values/ or record not found?

 

Thank you

Sandeep Rajput
Tera Patron

@Vamshi_ch123 Could you please update your script as follows.

 

answer = (function transformEntry(source) {
   
    var gr = new GlideRecord("cmdb_model");  
   gr.addQuery('name', source.u_model);
   gr.addQuery('manufacturer.name', source.u_make);
  gr.query();


   var returnVal = '';


   if(gr.next()){  


       returnVal = gr.display_name.toString();  


   }
   return returnVal;



})(source);