- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2023 10:59 AM
Hello All,
I have 2 model category with same name as Tablet device in model table and . I want to map only one model category(reference field on model table) in model table transform map when there is import which is correct and we don't want to map with old model .Could you please help me with field script of same .I think we can map with sys ID of correct model.
Thanks.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2023 08:50 AM
Hello @_bhishek
Sure thing,
First you'll need to create new system property records with a string value and set the value to the sys_id of the related model.
Then update your field map script to get the system property value like this:
answer = (function transformEntry(source) {
// Add your code here
if (source.u_model == 'Alienware M14x') {
return 'get(sys_property)';
}
else if(source.u_model == 'Alienware M17x')
{
return gs.getProperty('cmdb.model.sys_id.alienware_m17x');
}
else
{
var gr = new GlideRecord("cmdb_model");
gr.addQuery("name", source.u_model);
gr.query();
if (gr.next()) {
return gr.getUniqueValue();
}
}
})(source);
Now this does require a property for each sys_id you need to return. So the GlideRecord query can return sys_id's but however you can't use a system property.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 04:49 AM
I would suggest to return sys_id of the model
Also update the Referenced value field name field on field map - sys_id
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 05:52 AM
Hello Ankur ,
Could you please update script for better clarification.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 06:23 AM
update field map script as this
answer = (function transformEntry(source) {
// Add your code here
if (source.u_model == 'Alienware M14x') {
return 'sysId of G Series';
}
else if(source.u_model == 'Alienware M17x')
{
return "46c41083a9fe1981017c3925c2004930";
}
else
{
var gr = new GlideRecord("cmdb_model");
gr.addQuery("name", source.u_model);
gr.query();
if (gr.next()) {
return gr.getUniqueValue();
}
}
})(source);
update as this
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2023 04:51 AM
Hello Ankur,
Thanks for your response .
Could you please tell me how can i return sysIds through gs.get property .Could you please update the steps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2023 08:50 AM
Hello @_bhishek
Sure thing,
First you'll need to create new system property records with a string value and set the value to the sys_id of the related model.
Then update your field map script to get the system property value like this:
answer = (function transformEntry(source) {
// Add your code here
if (source.u_model == 'Alienware M14x') {
return 'get(sys_property)';
}
else if(source.u_model == 'Alienware M17x')
{
return gs.getProperty('cmdb.model.sys_id.alienware_m17x');
}
else
{
var gr = new GlideRecord("cmdb_model");
gr.addQuery("name", source.u_model);
gr.query();
if (gr.next()) {
return gr.getUniqueValue();
}
}
})(source);
Now this does require a property for each sys_id you need to return. So the GlideRecord query can return sys_id's but however you can't use a system property.