Transform map field map script

Mark Wood
Tera Contributor

Hello Experts,

I have written below field map scripting but it's not working can anyone please guide why it's not working.

answer = (function transformEntry(source) {

	if(source.u_model=="Apple Macbook Pro 16'' MVVJ2HB/A")
	{
var gr=new GlideRecord('cmdb_model');
gr.addEncodedQuery("display_nameSTARTSWITHApple Macbook Pro 16'' MVVJ2HB/A^short_descriptionLIKE32gb");
gr.query();
if(gr.next())
{
return gr.display_name; // return the value to be put into the target field
}

}
else{

	return source.u_model;
}

})(source);

thank you.

6 REPLIES 6

gajananvwit
Tera Contributor

Hi 

In this 

Apple Macbook Pro 16 MVVJ2HB/A

Do not use single quote ,wont consider string 

Use properly double quote 

hello @gajananvwit ,

In my Excel, it's an Apple Macbook Pro 16'' MVVJ2HB/A. That is why I am using the same thing in my script.

DYCM
Mega Sage

Hi @Mark Wood ,

Please elaborate issue you are facing, you are seeing some errors? Or you didn't get the result you expected? Can you please put the screenshots of these two models here?

Mark Wood
Tera Contributor

Hello @DYCM I am not getting the expected result. There are two models with the same name so I am checking the short description for the product model if the short description contains 32GB then am set that model.