Scheduled job for setting field value to true if two date fields values are same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 05:04 AM
Hi guys,
I have created on scheduled job script for setting one field value to trueautomatically when two dates field are same, but it is not working for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 05:29 AM
Can you try this:
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('u_current_date1', '!=', '');
ritm.addQuery('u_due_date1', '!=', '');
ritm.query();
while (ritm.next()) {
var currentDate = new GlideDateTime(ritm.u_current_date1.getValue());
var dueDate = new GlideDateTime(ritm.u_due_date1.getValue());
// Convert dates to the same format
var currentDateValue = currentDate.getValue();
var dueDateValue = dueDate.getValue();
// Compare the date values
if (currentDateValue == dueDateValue) {
ritm.u_account_expiry = true;
} else {
ritm.u_account_expiry = false;
}
ritm.update();
}
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 05:38 AM
Its not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 05:44 AM
Then please add logging to your script, so you can see the values that you are comparing.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 05:49 AM
@Mark Manders can you please guide me how to achieve that as I am new to servicenow