<div dir="ltr"><div>Thank you, I'll try that. So account_id holds the contact's parent's ID? I wouldn't have guessed that. Although, now that you point it out, I'm remembering that VT calls "organizations" "accounts" internally, so that does make more sense. I'll also look at event handlers to see if that would be a better fit.</div><div><br></div><div>A follow-up question, now that I think about it. Once I have the parent's ID, what's the best way to get all the parent's child contacts? A DB call? Web services? A simple method I don't know about? Thanks.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 18, 2018 at 5:12 PM, Alan Lord <span dir="ltr"><<a href="mailto:alanslists@gmail.com" target="_blank">alanslists@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I think you mean the "account_id" field?<br>
<br>
Just "get" the entity data for the id in that field.<br>
<br>
$accid = $entity->get('account_id');<br>
<br>
I do the same kind of thing in several customer's systems where they need a Primary and perhaps a Signatory contact.<br>
<br>
FWIW I tend to use an Event Handler rather than a workflow as it can't be disabled as easily.<br>
<br>
HTH<br>
<br>
Al<br>
<br>
<br>
<br>
On 18/06/18 20:42, Alex Hall wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello list,<br>
I've been asked to write a custom function for a workflow to run whenever a contact is updated. We have a custom field called "is primary contact", which is just a checkbox. However, each organization can only have one primary contact at a time. That means the custom function has to move the "primary" designation to the newly selected contact. Put another way, the function has to do these tasks:<br>
<br>
* get $entity's "is primary" custom field value<br>
* exit if the newly set value is false, as there's nothing to update<br>
* get $entity's parent organization (remember that $entity is from a contacts workflow)<br>
* set all the children contacts of $entity's parent organization to not be primary, while setting $entity itself to be the only primary<br>
<br>
My main problem right now is finding $entity's parent. I can't figure out how to do that. I've looked at the source code, but there's nothing in that class that seems to be a way of accessing the parent. What's the trick to this, or can it not be done how I want? Is there another way anyone can see to get this working? Hopefully I've explained enough to make sense. Thanks.<br>
<br>
-- <br>
Alex Hall<br>
Automatic Distributors, IT department<br>
<a href="mailto:ahall@autodist.com" target="_blank">ahall@autodist.com</a> <mailto:<a href="mailto:ahall@autodist.com" target="_blank">ahall@autodist.com</a>><br>
<br>
<br>
______________________________<wbr>_________________<br>
<a href="http://www.vtiger.com/" rel="noreferrer" target="_blank">http://www.vtiger.com/</a><br>
<br>
</blockquote>
<br>
<br>
______________________________<wbr>_________________<br>
<a href="http://www.vtiger.com/" rel="noreferrer" target="_blank">http://www.vtiger.com/</a><br>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div>Alex Hall<br></div>Automatic Distributors, IT department<br></div><a href="mailto:ahall@autodist.com" target="_blank">ahall@autodist.com</a><br></div></div>
</div></div>