UI policy

mayanksinghrath
Tera Contributor

i want to make a ui policy if the shortdescription contains some numbers a field should be visible i have hundred numbers

2 REPLIES 2

Bhavya11
Kilo Patron

hi @mayanksinghrath ,

 

you can write script in UI policy to make visibility of field depending on number present in short description field like

 

in UI policy

When to apply make condition like this Short description is not empty 

Go to Script tab and check the "Run scripts" checkbox (if not visible, make sure you are in advance view)

Then in script section(Execute if true),  you can try something like this

function onCondition() {
    var shortDesc = g_form.getValue('short_description');

    // Regex to check if any digit exists
    if (/\d/.test(shortDesc)) {
        g_form.setDisplay('your_field_name', true);
    } else {
        g_form.setDisplay('your_field_name', false);
    }
}

 

If this information proves useful, kindly mark it as helpful or accepted solution.

Thanks,
BK

Ankur Bawiskar
Tera Patron

@mayanksinghrath 

so what did you start with and where are you stuck?

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader