
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 01:30 AM
Can we restrict a choice list to a specific entry alone?
Am having a business application with cloud type as IaaS. I need to add an additional choice (CSP) under the choices tab in dictionary entry and restrict it to only one business application. Is that possible.
For example in the below BA could type should be marked as CSP and that choice should only be restricted to this BA. is that possible ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 07:24 AM
then do this
1) use list_edit ACL and block the edit operation
2) Now for form level do this (client script on table cmdb_ci_business_app)
a) create onLoad client script and check if the name is Infra-Cloud-Azure BA or Infra - Cloud BA, if yes then set the choice value and make readonly
b) in same onLoad if value is not that then remove that option from choice
function onLoad() {
var name = g_form.getValue('name');
if (name == 'Infra-Cloud-Azure BA' || name == 'Infra - Cloud BA') {
g_form.setValue('u_cloud_type', 'CSP')
g_form.setReadOnly('u_cloud_type', true);
} else {
g_form.removeOption('u_cloud_type', 'CSP');
}
}
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
01-28-2025 10:46 PM
the value in choice is csp and not CSP
so you need to give csp when you use removeOption
here is the updated code
function onLoad() {
var name = g_form.getValue('name');
if (name == 'Infra-Cloud-Azure BA' || name == 'Infra - Cloud BA') {
g_form.setValue('u_cloud_type', 'csp')
g_form.setReadOnly('u_cloud_type', true);
} else {
g_form.removeOption('u_cloud_type', 'csp');
}
}
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
01-28-2025 02:35 AM
in list view you cannot hide the option
2 ways to handle this
1) use before update BR and see if logged in user Doesn't belongs to group "Infra-Cloud-Azure BA" and Cloud Type [CHANGES TO] CSP -> then abort the BR
OR
2) don't allow list edit and it will stop the form update
Remember the 1st approach will work on both list and form view.
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
01-28-2025 04:51 AM
what's your requirement?
you want to stop user from selecting that option
OR
you want the choice value to be set with that option if the value is Infra-Cloud-Azure BA
Please mention the correct business requirement so that I can guide you.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 02:26 AM
Hello,
you can write a client script for this and hide the other choices (using removeOption) when BA name is Infra-Cloud-Azure BA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 02:27 AM
HI @Gautam Raj ,
You can try below script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// Assuming "Business Application" field is on the form
var baSysId = g_form.getValue('business_application'); // Replace with actual field name
var restrictedBA = 'sys_id_of_business_application'; // Replace with the sys_id of the specific BA
// Check if the current Business Application is the restricted one
if (baSysId == restrictedBA) {
// If it's the specific Business Application, only allow "CSP" in Cloud Type
g_form.setChoice('cloud_type', 'CSP');
g_form.setReadOnly('cloud_type', true); // Make it read-only if necessary
} else {
// Otherwise, allow all choices
g_form.setReadOnly('cloud_type', false);
}
}
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 03:49 AM
Hi @Runjay Patel Thanks for your response.
Below is the field value in the cmdb_ci_business_app
As per your suggestion i have created a client script as below but its not changing can you review the below code