Menu
SuiteCRM Pull Request Party hosted by SalesAgility
Welcome, Guest
Username: Password: Remember me

TOPIC: 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 on case list view, that can calculate different date between date modified and now. 4 days 5 hours ago #85834

  • woon
  • woon's Avatar
  • Online
  • New Member
  • Posts: 13
  • Karma: 0
Hi,

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
The administrator has disabled public write access.

How to add a new field on case list view, that can calculate different date between date modified and now. 4 days 3 hours ago #85836

  • ashish@outrightcrm.com
  • ashish@outrightcrm.com's Avatar
  • Offline
  • Elite Member
  • CTO at outright Systems
  • Posts: 262
  • Thank you received: 25
  • Karma: 4
Hi,
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.

store.outrightcrm.com/product/outright-utils/

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;	
}
The administrator has disabled public write access.

How to add a new field on case list view, that can calculate different date between date modified and now. 4 days 2 hours ago #85840

  • woon
  • woon's Avatar
  • Online
  • New Member
  • Posts: 13
  • Karma: 0
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.
Attachments:
Last Edit: 4 days 2 hours ago by woon.
The administrator has disabled public write access.

How to add a new field on case list view, that can calculate different date between date modified and now. 4 days 2 hours ago #85841

  • ashish@outrightcrm.com
  • ashish@outrightcrm.com's Avatar
  • Offline
  • Elite Member
  • CTO at outright Systems
  • Posts: 262
  • Thank you received: 25
  • Karma: 4
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.
The administrator has disabled public write access.
Time to create page: 0.064 seconds
Powered by Kunena Forum