How to make select box read-only based on another select box

Vinod S Patil
Tera Contributor

Hello Everyone,

My requirement is on catalog item,
Two variables are there and  types select box, 
                     1. Service (Options are: None, Depth and Patch)
                      2. ALM (Options are: None, MG and LM)

When I select the Patch in Service select box, ALM should set LM and it should be ready only.

Please suggest on this.

@Community Alums 
@Dr Atul G- LNG 

1 ACCEPTED SOLUTION

Vishwa Pandya19
Mega Sage

Hi Vinod,

 

You can use UI policy in the new Washington DC version.

Please refer screenshots below:

VishwaPandya19_0-1713152522457.pngVishwaPandya19_1-1713152541995.png

If you do not have Washington DC release, you can utilize client script to achieve the same.

VishwaPandya19_2-1713152661394.png

 

If my answer helped you in any way please mark it as helpful or correct.

View solution in original post

3 REPLIES 3

Maddysunil
Kilo Sage

@Vinod S Patil 

You can write onchange catalog client script on service field, please use the sample script below

 

var selectedService = g_form.getValue('service'); // Get the value of the Service variable
    var almField = g_form.getControl('alm'); // Replace 'alm' with the actual field name of your ALM variable

    // Check if the selected service is 'Patch'
    if (selectedService === 'Patch') {
        // Set the ALM field value to 'LM'
        g_form.setValue('alm', 'LM');
        // Make the ALM field read-only
        g_form.setReadOnly('alm', true);
    } else {
        // If the selected service is not 'Patch', enable the ALM field and reset its value
        g_form.setReadOnly('alm', false);
        g_form.setValue('alm', ''); // Reset the value to None or any default value you prefer
    }

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks

Vishwa Pandya19
Mega Sage

Hi Vinod,

 

You can use UI policy in the new Washington DC version.

Please refer screenshots below:

VishwaPandya19_0-1713152522457.pngVishwaPandya19_1-1713152541995.png

If you do not have Washington DC release, you can utilize client script to achieve the same.

VishwaPandya19_2-1713152661394.png

 

If my answer helped you in any way please mark it as helpful or correct.

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Vinod S Patil 

 

Greetings!!

 

You can do this via client script, and i think it is already provided @Vishwa Pandya19 @Maddysunil 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************