Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to show and hide 20 select option and on that basis 20 rich text/url field will show - catalog v

jaiho_rai
Kilo Sage

How to show and hide 20 select option and on that basis 20 rich text/url field will show - catalog variable 

 

e.g 

my variable name - Select Choice - Options are  - 1 ,2 ,3 ,4 ,5

RichText type or URL type variable - will be

www.123.com ,

www.xyz.com , 

www.abc.com

 

now - when in select option i will select - 1 then it will show only - www.123.com 

 

and so on.

could you help how i can achieve in catalog item ? client script or ui policy ?

 

1 ACCEPTED SOLUTION

Chaitanya ILCR
Mega Patron

Hi @jaiho_rai ,

you can have on change client script on the choice variable

with switch case something like I have shown the screenshot you can display the related variables

 

ChaitanyaILCR_0-1741197505370.png

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    switch (newValue) {
        case '1':
            g_form.setDisplay('richtext_backend_name', true);
            break;
        case '2':
            g_form.setDisplay('urlORrichLablebackendName', true);
            break;
//so on...
    }

    //Type appropriate comment here, and begin script below

}

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

View solution in original post

2 REPLIES 2

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @jaiho_rai 

 

UI policy is best , as it is no code.

*************************************************************************************************************
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]

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

Chaitanya ILCR
Mega Patron

Hi @jaiho_rai ,

you can have on change client script on the choice variable

with switch case something like I have shown the screenshot you can display the related variables

 

ChaitanyaILCR_0-1741197505370.png

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    switch (newValue) {
        case '1':
            g_form.setDisplay('richtext_backend_name', true);
            break;
        case '2':
            g_form.setDisplay('urlORrichLablebackendName', true);
            break;
//so on...
    }

    //Type appropriate comment here, and begin script below

}

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya