[Vtigercrm-developers] Workflow Custom Functions
Alan Lord (News)
alanslists at gmail.com
Wed Aug 25 00:39:34 PDT 2010
On 25/08/10 04:21, Musavir Khan wrote:
> going by memory $current_user should have current user information,
> $current_user is changed only for workflow tasks other than entity method.
I don't think this is the case. I just tried your method but it returns
19x1 (admin) even when I made the changes as another user (id 5).
I think the problem is that the workflow custom function is actually
being run as the admin user. This is why I think I need to query the
crmentity table for the modifiedby ID based on the entity that initiated
spawned the custom function.
So I'm thinking something like this should do it (just pseudo code):
function get_userName () {
// Get the id of the triggering entity (Potential)
$entity->get('id');
if crmentity->modifiedby > 1 then {
get username with the modifiedby value
} else
get username with the crmentity->smcreatorid value
}
return username;
}
Sound about right?
Cheers
PS: I can retrieve the user name directly from the $entity using
$entity->user->user_name (and even the first_name, last_name pair) But
this is *always* admin.
--
The Open Learning Centre
http://www.theopenlearningcentre.com
More information about the vtigercrm-developers
mailing list