- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2022 06:21 PM
I created a new field on my INC form. This field uses a BR to update with the current date when a new Customer Comment is added. To be reported on later (Show me Incidents without a Customer Comment in x number of days)
This is great going forward.
Would I be able to run a fix script to populate this field (u_last_customer_update) with the date of the most recent customer comment?
I have the below, but what comes after the = I'm not sure
var incGR=new GlideRecord('incident');
incGR.addEncodedQuery('active=true^u_last_customer_updateISEMPTY');
incGR.query();
while(incGR.next()){
incGR.u_last_customer_update=incGR.comments.created;
incGR.update();
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2022 07:01 PM
var incGR=new GlideRecord('incident');
incGR.addEncodedQuery('active=true^u_last_customer_updateISEMPTY');
incGR.query();
while(incGR.next()){
var journalEntries = new GlideRecord("sys_journal_field");
journalEntries.addQuery("name", "incident");
journalEntries.addQuery("element_id", incGR.getValue("sys_id"));
journalEntries.addQuery("element", "comments");
journalEntries.orderByDesc("sys_created_on");
journalEntries.setLimit(1);
journalEntries.query();
if(journalEntries.next()){
incGR.setValue("u_last_customer_update", journalEntries.getValue("sys_created_on"));
incGR.setWorkflow(false); // Not executing BR's
incGR.autoSysFields(false); // Not updating system fields such as updated by, updated
incGR.update();
}
}
Please check this if it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2023 12:53 AM
very very helpful