Clear value when field is hidden

Samuel Moya cam
Kilo Sage

Hi, 

I have a field that is hidden when the checkbox of another table is set to true.

And now I want this field to be clear whenever is hidden.
So far I have a UI policy with the following script set to true

function onCondition() {
if (!g_form.isVisible('u_model_details')) {
    g_form.clearValue('u_model_details'); // Clear the field value
    return true;
}
return false;
}

And the UI policy action clear the field value set to true, but is not working properly.
Any ideas??

Thank you and best regards.

1 REPLY 1

Runjay Patel
Giga Sage

Hi @Samuel Moya cam ,

 

Use below code instead of "isVisible" you can use "isFieldVisible".

function onCondition() {
if (!g_form.isFieldVisible('u_model_details')) {
    g_form.clearValue('u_model_details'); // Clear the field value
    return true;
}
return false;
}

 

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------