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

Hemanth M1
Giga Sage
Giga Sage

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.

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

Hi @Hemanth M1 ,

 

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

 

Thank you

Sandeep Rajput
Tera Patron
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);