Updating date field in previously resolved tickets
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hello all,
I am attempting to update a date field when a ticket was changed to resolved state. I was trying to use a glide walker, but I don't see that plugin in our list of installed (unless I'm not looking in the right place). I have checked to make sure that audit is selected on the form in question. I have updated the form so that when the state is marked as resolved it will update the resolved date field correctly, but now I'm trying to updated previously resolved tickets.
The fix script I tried:
var gr = new GlideRecord('u_content_requests');
gr.addQuery('state', '5');
gr.addNullQuery('u_resolved_date');
gr.query();
var count = 0;
while (gr.next()) {
var hw = new sn_hw.GlideHistoryWalker(gr.getTableName(), gr.getUniqueValue());
if (hw.walkToFieldValue('state', 'resolved')) {
var historySnapshot = hw.getUpdateSnapshot();
var actualDate = historySnapshot.sys_updated_on;
gr.u_resolved_date = actualDate;
gr.setWorkflow(false);
gr.autoSysFields(false);
gr.setLimit(10);
gr.update();
gs.info("Success: Updated " + gr.number + "with date: " + actualDate);
count++;
}
else {
gs.warn('no history found for content request: ' + gr.number);
}
gs.info('fix script for content requests completed. total updated: ' + count);
}
Any insight or assistance would be appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
If Your table/application is having any backend flow/workflow, it is best using that you can store the previous value of your Date field in scratchpad and use that till end of the flow.
You can do it using by hitting audit table if your custom table is audited. BUT it is not at all recommended. it can cause performance issue of your instance in long run.
