On Load client script is not working to make checkbox true if another date field is not empty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2024 12:02 AM
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 -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2024 11:57 PM
@Jitendra Diwak1 yes by saving the form we can save our data in backend and this will update the form but it will not work if both assignment group and assign to is filled then what to do?
I think running a scheduled job will work in this case so that it will automatically save the record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 12:00 AM
Hi @abhaysingh98,
It will work in same manner. you do not need to run any schedule job. to perform the database operation, you need to save the data.
Please accept my solution if it resolves your issue and thumps up
Thanks
Jitendra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 12:14 AM
Hi @abhaysingh98 ,
I tried in my pdi working as expected with below script
function onLoad() {
var dateFieldValue = g_form.getValue('u_glide_date_field');
alert(dateFieldValue);
if(dateFieldValue == null || dateFieldValue == ''){
g_form.setValue('u_check_box', false);
alert('FALSE');
}
else if (dateFieldValue != null || dateFieldValue != '') {
g_form.setValue('u_check_box', true);
alert('True');
}
}
Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 12:17 AM
@Anand Kumar P have you checked in XML if this value of checkbox is saved as true or not?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 03:25 AM
@abhaysingh98 you are writing script on client side, xml it will show the data which is saved in the database not the onload value of the checkbox.
Thanks,
Anand