How to add a new field on case list view, that can calculate different date between date modified and now.


How to add a new field in the list view of case module:

  • show different DateTime between date_modified and now.
  • so the user knows how long the case does not update easily.

I know it can be achieved by workflow, but I don’t want the database to keep read and write. Can I make the different date show on the list view and doesn’t need to store in the database? and how to achieve it?

suiteCRM version 7.11.5

Here are steps to achieve this…

  1. Create a non-db Fields from code… let’s call it, Case Duration.
  2. Make a process record hook to dynamically pull it’s value after each reload.
  3. Call this function outright_get_duration($now_date,$bean->call_duration)

You may use free outright utils package from my store, to avail use of those function.

It’s free and easy to install.

if you don’t want to install it, just copy this function to any of your Extended UTILS.

function outright_get_duration($endtime,$starttime){	
	$duration_arr = array();
	if(isset($endtime) && isset($starttime)){
		$diff = date_diff(date_create($starttime), date_create($endtime) );		
		$duration_arr =  array(
				'yr' => $diff->y,
				'mon' => $diff->m,
				'day' => $diff->d,
				'hr' => $diff->h,
				'min' => $diff->i,
				'sec' => $diff->s
	return $duration_arr;	

sorry, I don’t get what you mean. I still prefer not to install anything yet.

Maybe can add some custom code in listviewdef.php like the image I attached.
But I dunno how to write, so it can calculate the different DateTime with now and date_modified.

My code:
{$DATE_MODIFIED} can display the date modified of the cases, but
{$now_date} can’t display current DateTime.

The function already provided(outright_get_duration), so no need to install anything. This function takes 2 parameters in date , calculate its difference and return difference in Year,month,day , hours , mins. Is that not what you need?

However, I am not sure it will perform that calculation in the custom_code field.

You can copy that code to any function utils file and you can use “function” parameter in vardef as well. Both process and function parameter should work.