Make multiple choice field's option read-only

Ankita9793
Tera Contributor

Hi All,

 

I have a 'Multiple Choice' field called request type, i want to make 'Change/Move' option ready only on form load.

 g_form.setReadOnly(); didn't work, please suggest.


Screenshot 2025-08-11 210912.pngScreenshot 2025-08-11 210949.png

3 REPLIES 3

kaushal_snow
Mega Sage

Hi @Ankita9793 ,

 

The setReadOnly() function works at the field level, it doesn’t allow selective read only of individual choice list values.

 

 

Thanks and Regards,
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/

Try using Onchange script

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) return;

var fieldName = 'your field name'; 
var blockedValue = 'Your choice value ';

if (newValue === blockedValue) {
g_form.showFieldMsg(fieldName, '"' + blockedValue + '" cannot be selected.', 'error');
g_form.setValue(fieldName, oldValue);
}
}

 

If you want the Your option to look unselectable while still being visible, you’d need to override the UI via DOM manipulation using onload

 

If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.

 

 

Thanks and Regards,
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/

Shashank_Jain
Kilo Sage

Hello @Ankita9793 ,

CC: @kaushal_snow,

 

 

As per my understanding, it is not possible to make a specific choice read-only for a variable with the data type Multiple Choice in ServiceNow.

However, we can implement a workaround to achieve a similar result.

Scenario:

We have a Multiple Choice variable named "test1", with the following choices:

  • "one"

  • "two"

We want to prevent users from selecting the choice "two", which is essentially what we were trying to achieve by making it read-only.

 

Solution:

We can write an onChange Catalog Client Script. When the user selects the option "two", the script will:

  • Display a alert message: "Option 2 is not selectable."

  • Clear the selected value from the field

Script used :

function onChange(control, oldValue, newValue, isLoading) {
  if (isLoading || newValue == '') {
    return;
  }
  if (newValue == '2') {
    alert('Option 2 is not selectable.');
    g_form.clearValue('test1'); // Reset variable
  }
}
 

This approach doesn’t make the option read-only, but it effectively prevents the user from selecting it.

Screenshots are attached for better understanding.

 

If this solution was helpful, please mark it as helpful and complete the thread

If this works, please mark it as helpful/accepted — it keeps me motivated and helps others find solutions.
Shashank Jain