Last Account Activity Dashlet
Hello, I am trying to create a Dashlet wich will show me my accounts and the date of the last activity (task, call or meeting) related to this account. I made a copy of the MyAccounts dashlet and started modifying what I needed.
this is the process function:
function process($lvsParams = array()) {
if (isset($this->displayColumns) && array_search('lastActivityDate', $this->displayColumns) !== false) {
$lvsParams['custom_select'] = ', lastActivityDate';
$lvsParams['custom_from'] =
"
LEFT OUTER JOIN
(
SELECT
parent_id,
date_start as lastActivityDate,
name as lastActivityName,
lastActivityUserId,
lastActivityUserName
FROM
(
SELECT name, act.date_start,
act.parent_id, act.parent_type, assigned_user_id
FROM activities act,
(SELECT parent_id, parent_type, MAX(date_start) date_start
FROM activities
GROUP BY parent_id, parent_type
) last_act
WHERE act.date_start = last_act.date_start AND
act.parent_id = last_act.parent_id AND
act.parent_type = last_act.parent_type AND
act.parent_type = 'Accounts'
) last_activity
LEFT OUTER JOIN (SELECT id as lastActivityUserId, user_name lastActivityUserName FROM users) uact
ON last_activity.assigned_user_id = uact.lastActivityUserId
) last_activity
ON accounts.id = last_activity.parent_id
";
}
parent:: process($lvsParams);
}
}
The generated query works exactly as needed, it returns the data from the account plus the date of the last activity.
So far, I can add my dashlet to my home screen, the dashlet shows the account's data, but the new column lastActivityDate is empty on the dashlet. I did some debugging and this problem seems to be because this column its not defined in the Accounts fields.
Can please someone help me with this ?
Edit:
I am using CE 5.5.1
Last edited by hotquik; 2011-08-29 at 02:10 PM.
» Operating system type and version: Windows 2003 Server
» Sugar version and edition: 5.5.1 Community Edition
» Webserver type and version: IIS 6
» PHP version: 5.2.11
» MS SQL server 2008 version
Bookmarks