How to capture it for existing Problem Tickets which are already in Root Cause Analysis state?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2025 12:08 PM
I am able to populate time taken by problem ticket from state change from new to Root Cause Analysis,
How to capture it for existing Problem Tickets which are already in Root Cause Analysis state?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
For existing Problem records already in Root Cause Analysis state, just run a one-time background script to calculate and populate the time field.
var gr = new GlideRecord('problem');
gr.addQuery('state', '101'); // Replace 101 with your RCA state value
gr.addNullQuery('u_time_to_rca'); // Only if your field is empty
gr.query();
while (gr.next()) {
// Assuming 'sys_updated_on' is when it entered RCA, adjust if you track it differently
var created = new GlideDateTime(gr.sys_created_on);
var rca = new GlideDateTime(gr.sys_updated_on);
var diffMillis = GlideDateTime.subtract(rca, created);
gr.u_time_to_rca = diffMillis.getNumericValue(); // Or format as needed
gr.update();
}
That way you:
- Keep your business rule/flow for new tickets as-is.
- Use this script only once to backfill historical data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
@Rafael Batistot Thanks for the response, I tried to run in Background Script but its not working.