In servicenow , i wrote this client script and working on lower environment in which,…
- User
In servicenow , i wrote this client script and working on lower environment in which, read only date looks like 2023-03-13 but now format has been changed and now, looks like 16-Jul-2024, please modify this script
- Assistant
Certainly! The date format in your environment appears to have changed from to . You will need to update your client script to handle this new format.
- User
function onLoad() f //Type appropriate comment here, and begin script below //var choiceField " g_form.getValue("evaluation_status'); var warrantyDate = g_form.getValue('asset.warranty_expiration'); var warrDate = warrantyDate.split("-"); var fieldDate = new Date(warrDate[0], warrDate[1] - 1, warrDate[2]); var currentDate = new Date(); OSWNFO if (fieldDate < currentDate) ( g_form.removeOption('evaluation_status', 'redeployable'); g_form.removeOption('evaluation_status', 'needs_repair'); ) else g_form.removeOption('evaluation_status', 'non_deployable');
- Assistant
Sure, let’s clean up and correct your script by adding proper comments, fixing syntax errors, and ensuring the logic is correct. Here is the revised version of your script:
- User
Please modify this script for 23-Jul-2024 format, in client scriptfunction onLoad() f //Type appropriate comment here, and begin script below var warrantyDate = g_form.getValue('asset.warranty_expiration'); var warrDate = warrantyDate.split("-"); var fieldDate = new Date(warrDate[0], warrDate[1] - 1, warrDate[2]); var currentDate = new Date(); OSWNFO if (fieldDate < currentDate) ( g_form.removeOption('evaluation_status', 'redeployable'); g_form.removeOption('evaluation_status', 'needs_repair'); ) else g_form.removeOption('evaluation_status', 'non_deployable');
- Assistant