UI Policy action

KiranmaiP
Tera Contributor

I have a catalog and form, where I have to implement the requirement:

if engagement id : 1234, then private checkbox should be auto checked means true. Private checkbox is true/false type field on table.
How to implement in form view and workspace view?

 

In catalog view, there is catalog UI Policy action created with value action : Set value and value true.
but in form view, UI policy action I dont see value action, I can see only clear the field value.

Please Help me with form view and workspace view

 

8 REPLIES 8

So by condition, you want to set the value if I understood correctly. So this can follow below or another way is to the Client script. 

 

 

function onLoad(){

g_form.setValue('variable', name);

}

https://www.servicenow.com/community/developer-forum/script-ui-policy-to-set-a-variable-set-variable...

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

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

Ankur Bawiskar
Tera Patron
Tera Patron

@KiranmaiP 

Since you want to set the value, please use onChange client script which applies on both the view

onChange on Engagement id

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

    if (newValue == '1234')
        g_form.setValue('privateCheckboxVariable', true);
    else
        g_form.clearValue('privateCheckboxVariable');

}

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Here, engagement id is reference field, so I wasnot able to use this code, it is referring to another opportunity table with opportunity id field 

Hi @KiranmaiP,

 

Since Engagement ID is reference field, you need add the sys_id of the '1234' record in the if Condition.

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

    if (newValue == 'SYSID_OF_1234')
        g_form.setValue('privateCheckboxVar', true);
    else
        g_form.clearValue('privateCheckboxVar');

}

 

If you found my response helpful, please mark it as Solution and Helpful.

 

Thanks and Regards,

Ehab