how to disable options in choice list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2017 05:01 AM
Hello,
We need to disable/unselectable some choices in the state field. In helsinki version we were using 'document.getElementById' to disable the option in the onload client script and is working fine. But when our instance got upgraded to Jakarta it is not working... all the choice list options were selectabe by the users where it should not.
Based on the suggestion provided 'https://www.servicenowguru.com/scripting/client-scripts-scripting/removing-disabling-choice-list-opt... ' I tried to write a new UI script and called that function in onload client script but it is not working.
Can anyone help me in fixing this issue.
The weird part is 'document.getElementById' is working in my personal developer instance which is in Jakarta version.
Regards,
Sathish.K
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2017 05:22 AM
Hi Sathish,
Without using DOM manipulation it cannot be disabled. One approach if you want to avoid dom is that onChange of that drop down field show alert that this drop down cannot be selected.
What's the purpose of showing those if they won't be used based on some condition. Use this condition and in onLoad disable those options. This will be the easiest approach.
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2017 01:41 AM
Hi Sathish,
Any update on this?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2017 07:42 AM
Hi Ankur / Chuck,
We get it fixed. They want the fields to be displayed but shouldn't selectable. Two fields with this issue "State" and "Contact Type". Those options will be used when incident created from portal / through integrations but user should not select from incident form.
We disabled the client scripts which using the DOM to hide this options and written a new UI Policy. In the script, we included jQuery and HTML to fulfill this requirement.
Using getAttribute we got the element id and using setAttribute we disabled those options.
Thanks for your suggestions.
-Sathish.K
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2017 08:53 AM
Sathish,
This is what I am looking for. Can you share the script here?
Thanks,
Rajini
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2021 10:21 PM
Hi Rajinis,
I have a similar kind of requirement. In case you get the solution, could you please share the tech docs for the same.
Thanks & Regards,
Abhi