Import Set

Mark Wood
Tera Contributor

Hello Experts,

I want to import the stock rule into the stock rule table. In my excel model, the name is Apple Macbook Pro 16'' MVVJ2HB/A

but in the product model table, there are multiple product models with the same name, that is Apple Macbook Pro 16'' MVVJ2HB/A but their specifications are different. my model specification should be 16-inch 32 GB.please guide me thank you

4 REPLIES 4

Saurabh Gupta
Kilo Patron
Kilo Patron

Hi @Mark Wood ,
You can a scripted field mapping to map the correct model.

 

Servicenow Transform Map Script Example | Data Source & Import Data into ServiceNow Instance - YouTu...


Thanks and Regards,

Saurabh Gupta

Hi @Mark Wood 
Did your issue get solved?

 

C

If the provided solution meets your needs, kindly consider marking it as helpful and accepting it as the solution. This helps others who may have similar questions.


Thanks and Regards,

Saurabh Gupta

Hello @Saurabh Gupta  ,

its not yet resolved i have written field map scripting could you please guide me why the below script is 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);

Hi @Mark Wood 
You can write script as below-

answer = (function transformEntry(source) {

	if(source.u_model=="Apple Macbook Pro 16'' MVVJ2HB/A")
	{
var gr=new GlideRecord('cmdb_hardware_product_model');
gr.addEncodedQuery("name=MacBook Pro 15"^model_number=MD322LL/A");// You can change this query as per your need
gr.query();
if(gr.next())
{
return gr.getUniqueValue(); // return the value to be put into the target field
}
else
{
return "";
}
}
else
{
return "";
}

})(source);


How to get Query-

SaurabhGupta_0-1705064406207.png

 




Thanks and Regards,

Saurabh Gupta