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

abhaysingh98
Tera Contributor

@Jitendra Diwak1 thanks, it worked.😊

abhaysingh98
Tera Contributor

Hi @Jitendra Diwak1 

 

By using UI Policy it is only working in frontend as I checked in XML it is not updating please see attached screenshot.

 

Hi @abhaysingh98,

 

could you please check in another instance if the issue persist?

 

Please accept my solution if it resolves your issue and thumps up

 

 

Thanks

Jitendra

Please accept my solution if it works for and thumps up.

@Jitendra Diwak1 , Yes I have checked in other instance also the issue is there because UI policy only change data in frontend it will not save data in database.

Hi @abhaysingh98,

 

Yes, I agree with it but UI Policy works on front end and then you have to save the form. Suppose you have assignment group and assigned to field on Incident table if assignment group is not empty then assigned to field should be mandatory. At that time you will have to fill data and you try to see the xml then data will be not there.

 

Please accept my solution if it resolves your issue and thumps up

 

Thanks

Jitendra

Please accept my solution if it works for and thumps up.