
- 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 04:34 AM
Hi @Gautam Raj ,
Are you checking at list level? it will work on form level. You should not allow option changes from list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 06:24 AM
Thank you for marking my solution as helpful! If my answer addressed your query, feel free to accept it to help others in the community benefit as well.