Assigned User for Calls Module

Good day Everyone

I am working on a custom module where I need to add data to the Calls log. Below is my code.

$bean = BeanFactory::newBean(‘Calls’);
$bean->name = ‘This is a test’;
$bean->parent_type = $parent_type;//Accounts, Leads, Contacts
$bean->date_entered=date(‘Y-m-d H:i:s’);
$bean->date_start=date(‘Y-m-d H:i:s’);
$bean->status=“Planned”;//Planned, Held, Not Held

The above code is working fine. The record gets added. What I need to know is how to assign the current logged in user to the call.

Any help would be kindly appreciated. Thank you very much in advance.

Something like

$bean->assigned_user_id = "2af45841-d256-9f58-0097-5d44490eac9b";

To get the id from a user record you can use of the normal bean functions.

Hello @pgr

Thank you very much. I figured something out so far. This is what I use

When I do it this way, it is saved correctly.

So now I’m trying to figure out how to get the “seed_sally_id” part from the user data, because when I use global $current_user; I’m only getting blank info back

Doesn’t this work?

global $current_user;
$bean->assigned_user_id = $current_user->id;

Unfortunately it does not work. Just tried it.

Have a look in the $GLOBALS array, there’s a lot of stuff in there. I am hoping you have a debugger (IDE) plugged into to your code so you can inspect this easily.

Thank you @pgr. I do have a debugger. What I’m trying now, is to send the data I need via my javascript to my module. That should basically work



I just found an example in my code where I use that.