Hi,
I have a custom field on my lead table that I would like to update anytime a user save a new log call.
I have been trying to look the code in call.php and CallFormBase.php, I get that I should change something in the function call() but I dont really understand where/what is the real function called when the user click save.
I think I should do something like:
$MyField = new Call();
$MyField->retrieve(‘my lead id’);
$MyField->Touch_Phone = ‘1’;
$MyField->save();
Hi,
not sure with workflow …i give the direction :
first workflow
create workflow for call module
for all record, or new record, for save or modified…
action, record type lead … action update your custon field
Not sure when the workflow is fired, after save, after relationship add (very important)
second logic hook (you must work on call module)
you must distinct new or modified record (this is the real “must to know” )
the sample you provide is bad, is not “new Call” but it must be “new Lead”
i dont know if you can retreive ID of lead relationship, maybe you must in logic hook load relationship.
If you understand, the problem is retrieve the related id of lead (relate field ou many to … is not same).
You don’t have this id for new record call, the call is saved in database (for have a id) and then the call is saved and related in table leads_calls with the id of call. !
Thank you, since the field is calculated (increment) I can’t use a worflow
Would it works if I create a function in Call.php:
function increment_phone()
{
$query = “SELECT touches_phone_c from leads_cstm where id_c=’$this->lead_id’”;
$result = $this->db->limitQuery($query,0,1,true," Error filling in additional detail fields: ");
$new_NbCall = $result + 1;
$db -> query(“update leads set touches_phone_c = ‘$new_NbCall’ where id_c = ‘$this->lead_id’”);
}
and then I’m calling it when the call is saved (in CallFormBase.php, not sure where… though)
Thanks, where should I write this query and the update? on Lead.php in modules?
Also do I create a logic hook from the CRM itself or it has to be a new php file?