Issue with Populating 'Customer' Field from Reference Table in ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 01:30 AM
I am experiencing an issue with a select box field named "customer" in ServiceNow. The field has the following choices and backend values:
- Very Low (1)
- Low (2)
- Moderate (3)
- High (4)
- Very High (5)
This field is populated from the cmdb_ci_business_app table using dot-walking. When I select "existing digital platform," the customer field should be populated from the table. However, if the customer value is empty (none), it should display as "None" or remain empty in the form. Currently, it is showing as '0'.
Could you please help me understand why this is happening and how to fix it?
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 03:16 AM
Hi @NikhithaNikki,
---------------------------------------------------------------------------------------------------------------------------------
I got your problem
When you're trying to auto-populate your variable using the Customer field (which is a choice field), it’s actually pulling the backend value of that choice. If the value is "none", it typically resolves to null, which is interpreted as 0—hence the unexpected result.
To resolve this, I recommend the following:
Remove the auto-population configuration from the variable record.
Instead, create a client-callable Script Include that retrieves the value from the Customer field.
Then, use a Catalog Client Script (onChange) on the field that holds the related record and then call it in catalog client script.
This approach gives you more control and ensures accurate data mapping without unintended values.
Catalog client script: -
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if (newValue == '') {
g_form.setValue('customer', '');
}
var gaINC = new GlideAjax('global.community'); //replace with you Script include name
gaINC.addParam('sysparm_name', 'fetchDetails'); //replace with function name
gaINC.addParam('sysparm_incident_id', newValue); //passing the sys_id of record from which we want the value
gaINC.getXMLAnswer(function (response) {
var result = response;
if (result == null) {
g_form.setValue('customer', 'None'); //setting the value
} else {
g_form.setValue('customer', result);
}
});
}
I hope now your issue will be solved if not Please let me know
-------------------------------------------------------------------------------------------------------------------------------
Please Mark my Response Helpful and Accept as solution.
Thanks & Regards
Mayank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 03:25 AM
@NikhithaNikki, one more Step -> Change your Catalog Variable "Customer" from Select Box to Single Line Text.
-------------------------------------------------------------------------------------------------------------------------
Please Mark my Response Helpful and Accept as solution.
Thanks & Regards
Mayank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 03:26 AM
The field on dictionary should be Made of Type "String" or "Choice"
Why it's an integer?
Ensure the variable type and field type are same to avoid issues when you use "Auto populate" feature.
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
07-08-2025 03:47 AM
That is exactly my comment above.
@NikhithaNikki have you had chance taking into this?
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 05:03 AM
@NikhithaNikki,
Have you had a chance to try what I suggested? I tested it using the same integer-type field, and it worked perfectly.
-----------------------------------------------------------------------------------------------------------------------------------
Please Mark my Response Helpful and Accept as solution.
Thanks & Regards
Mayank