Change Request Variable True

MK21
Tera Contributor

Hi All,

 

I have a requirement in Change Request form, in the category field below are the choices, when we select the below choices , another varible called CMDB checkbox, automatically it needs to checked , how to acheive this 

 

Decommission - Application
Decommission - Application & Server
Decommission - In Build or Non operational CI 
Decommission Server
System / OS upgrade
Tech Refresh / Server Migration
Project go-live

1 ACCEPTED SOLUTION

SunilKumar_P
Giga Sage

Hi @MK21, you can also try the onChange client script on category field.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    if (newValue == 'Decommission - Application' || newValue == 'Decommission - In Build or Non operational CI' || newValue == 'Decommission Server' || newValue == 'System / OS upgrade' || newValue == 'Tech Refresh / Server Migration' || newValue == 'Project go-live') {
        g_form.setValue('cmdb', true);
    } else {
        g_form.setValue('cmdb', false);
    }

}

 

Regards,
Sunil

View solution in original post

12 REPLIES 12

Hi @MK21 

 

Try like this:

g_form.setValue('fieldname', 'True');

 

or

 

function onCondition() {
g_form.setValue('category', Server);
}

 

In these

LearnNGrowAtul_0-1707744870956.png

 

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

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

Hello Atul,

 

MK21_0-1707745946954.pngfor this category below are the choices 

 

Decommission - Application
Decommission - Application & Server
Decommission - In Build or Non operational CI
Decommission Server
System / OS upgrade
Tech Refresh / Server Migration
Project go-live

 

when we select above choices below variable needs to auto check automatically

MK21_1-1707746048975.png

Please help on this when change is Normal

 

 

 

In UI policy add condition

type = Normal &

category is one of as above

 

Then go to script section

and bring another field as visible and 

set value as per last comment.

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

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

SunilKumar_P
Giga Sage

Hi @MK21, you can also try the onChange client script on category field.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    if (newValue == 'Decommission - Application' || newValue == 'Decommission - In Build or Non operational CI' || newValue == 'Decommission Server' || newValue == 'System / OS upgrade' || newValue == 'Tech Refresh / Server Migration' || newValue == 'Project go-live') {
        g_form.setValue('cmdb', true);
    } else {
        g_form.setValue('cmdb', false);
    }

}

 

Regards,
Sunil

Andrew_TND
Mega Sage
Mega Sage

As per above, I'd recommend a UI policy for a no code solution as per the above replies.

If you wanted to client script it, it would look something like this...

//on change

var type = g_form.getValue('type'); // Field name with the choices stored.
var cmdb = g_form.getValue('cmdb');

if (type == 'choice_1' || type == 'choice_2' || type == 'choice_3') { //Your choices 
g_form.setValue('cmdb', true).
} else{
g_form.setValue('cmdb', false);
}
}


Please mark as helpful or if its resolved your issue, mark as correct!