Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

MakeAndModelJS SncMakeAndModel update the query to use company sys_id rather than company name

Steven Watts2
Tera Guru

Hi,

 

Is it possible to update the functions within the MakeAndModelJS script include to query the company record sys_id rather than name? 

 

* @Param mfrName The manufacturer name. <-- This would be the sys_id instead.
 * @Param modelName The model name.
 * @Param modelType The model type name.
 
I can see that the functions make use of the SncMakeAndModel class which I believe is an internal Java class that we don't have access to.
 
Use case:
 
We have multiple records in the core_company table with the same name so this is causing us issues with the MakeAndModelJS SI not returning the correct company/manufacturer. Whilst we will review the data to see what can be cleaned up i'd also like to investigate alternative solutions.
 
Steven
2 REPLIES 2

Steven Watts2
Tera Guru

@Harish Bainsla @Kieran Anson 

 

Hi both,

 

I can see that you've both answered questions on similar topics before so wondering if you have any input/idea on the above? I'm looking to confirm how/if the functions can be updated to use the company record sys_id rather than the name.

This is one of the functions in question:

MakeAndModelJS.fromNames = function(make, model, modelType) {
	var modelTable = SncMakeAndModel.determineModelTableName(modelType);
	var makeAndModelJava = SncMakeAndModel.fromNames(make, model, modelTable);		
	var mm = new MakeAndModelJS(makeAndModelJava);		
	return mm;
};

 

Make in the above is the company name which is being passed to SncMakeAndModel. 

 

Steven

I'd suggest looking into using the normalisation data service. It's the intended way to a canonicalise your company names and is the intended method. The MakeAndModelJS uses this same behaviour and is why it wants the display value of a company - it'll internally use the normalisation engine to identify the correct company record.

 

https://docs.servicenow.com/csh?topicname=c_NormalizationOverview.html&version=latest