Calculated Integer Field value not showing in List view

MStritt
Tera Guru

I've created a new field on the Case Table called 'Days Open' (days_open). Type is Integer. I've created a Business Rule to calculate the amount of Days a Case is Opened based on the 'Opened' (opened_at) value. I'm seeing the correct value in the field on the Case form, but I'm not seeing the value in the Days Open column/field in List view. Or, when running a report or query.

 

MStritt_0-1725914939639.png

 

 

(function executeRule(current, g_scratchpad) {
    // Ensure the Case has an opened_at date before calculating
    if (current.opened_at) {
        gs.info('Opened_at date found for Case: ' + current.number);

        // Convert the 'opened_at' field to a GlideDateTime object
        var openedAt = new GlideDateTime(current.opened_at);
        var now = new GlideDateTime();
        
        // Calculate the difference in milliseconds
        var durationMS = now.getNumericValue() - openedAt.getNumericValue();
        
        // Convert milliseconds to days
        var daysOpen = Math.floor(durationMS / (1000 * 60 * 60 * 24));
        
        gs.info('Days Open calculated: ' + daysOpen + ' for Case: ' + current.number);

        // Set the calculated days to the u_days_open field
        current.u_days_open = daysOpen;
    } else {
        gs.info('No opened_at date found for Case: ' + current.number);
    }
})(current, g_scratchpad);

 

4 REPLIES 4

MStritt
Tera Guru

The Days Open value is automatically updated, when anyone opens a Case. I'll have a scheduled job, that will run once per day, that will update the Days Open values. 

Hey Matt,


If you have a scheduled job that runs every day. Why do you require the Business Rule to be updated?

Shouldn't the scheduled job update the "days" on a daily basis?

 

Hi Neel,

 

Yes, it will updated daily. But, it can always be updated in real time, if/when the Case is opened. But, my main problem, is that I'm not seeing the value in the Days Open column in list view. I can see it in the field on the form, but not in list view. This is really where I need it to be seen. And, when running reports. 

Amit Garg
Tera Contributor

Hi Matt,

 

Looks like you are using a display business rule. The BR will make sure that the value on the field is populated when form loads but it won't be saved until the record is manually saved. The reports will use the database values and since the form was not saved no value will be available to reports. And in case reports has some values populated there will always be some discrepancies between data shown on the form and the report data.