State visible according to country variable in form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2025 02:24 AM
I have this form in record producer , shipping country and shipping state -> select look up type -> referencing to "cmn_location" table.
I want state and city to comes according to selected country.
i.e. if i select "INDIA" in shipping country then state of India should be visible in "shipping state" variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2025 06:57 AM
Understood and sorry for missing that aspect. Perhaps, do a query then like this:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// Clear the shipping state field
g_form.setValue('shipping_state', '');
g_form.setQuery('shipping_state', 'country=' + newValue);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2025 06:10 AM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
// Clear state options on load or if country is cleared
g_form.clearOptions('shipping_state');
return;
}
// Set reference qualifier on shipping_state to only show states whose parent is the selected country sys_id
var filter = 'parent=' + newValue;
g_form.setFilter('shipping_state', filter);
// Clear shipping_state value so user can re-select appropriate state
g_form.setValue('shipping_state', '');
}
onChange Client Script
Thanks, and Regards,
Suyash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2025 06:11 AM
you can use script for this
what did you start with and where are you stuck?
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-27-2025 06:16 AM
I have tried to use this reference qualifier, but this didn't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2025 07:09 AM - edited ‎05-27-2025 07:16 AM
Hello @SimranS04382950,
You can simply use a reference qualifier as below:
Reference qual - javascript: '<enter your country field name from cmn_location table>='+current.variables.shipping_country;
Output -
Please mark this as "correct" and "helpful" if you feel this answer helped you in anyway.
Thanks and Regards,
Ashish