[Vtigercrm-developers] Function vtws_revise creates an incorrect history entry

Preexo preexo at googlemail.com
Tue Jun 7 07:34:14 GMT 2016


@MrJingles - This is a thorough description! :) 

When custom functions are called through workflows, the parameter $entity
that  you are using in your custom function is always the entity to which
the workflow is attached. So in your case, in Scenario 1 $entity will
contain the apartment entity. But in Scenario 2, $entity will contain the
contact entity. 
But you are using the contact entity in Scenario 2 as if it was the
apartment entity. It's two different entities though. In your second
scenario, $entity->id is not giving you the apartment id, it gives you the
contact id, because it's a contact workflow.

I suggest you write a second custom function first, which you call when
saving contacts.
In that, you get the apartment id from the contact. Some metacode would be
something like this (your apartment id will probably look different, maybe
more like cf_xxxx):

...
$apartmentid = $entity->apartment_id; 


Anyhow, I suggest you try to decouple the second Scenario in a seperate
function and get it to work there first.
Afterwards we can go and compare the functions and see if they could
actually be merged into a more generic one - if it's worth it at all.

Hope this made sense, I am still a learner myself and not always correct
either, please write again in case you are missing something.



--
View this message in context: http://vtiger-crm.2324883.n4.nabble.com/Function-vtws-revise-creates-an-incorrect-history-entry-tp19167p19175.html
Sent from the vtigercrm-developers mailing list archive at Nabble.com.


More information about the vtigercrm-developers mailing list