On Load client script is not working to make checkbox true if another date field is not empty.

abhaysingh98
Tera Contributor

Hi All,

I am new to ServiceNow and facing an issue, I have written an on load client script to make checkbox true if other date field is not empty.

As per my understanding my code is correct but is is not executing.

 

ON Load Script -

 

function onLoad() {
    var dateFieldValue = g_form.getValue('u_due_date_2');
   
    if(dateFieldValue != '') {
        g_form.setValue('u_account_expiry', true);
    }

}
17 REPLIES 17

@Anand Kumar P  I want to save the data in database what can I do to achieve it.

@abhaysingh98  Try  In client side with g_form.save() if it not works .  You have to convert it to before business rule then only it will saves to database.

 

Community Alums
Not applicable

abhaysingh98 try this

g_form.setValue('u_check_box', 'false');

note on the single quotation marks. I faced this issue recently and that solved my problem. I don't understand why but as long as it fixed my issue!