<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">That's a good idea. I'm not sure it will work with the interface I'm thinking of using, but I'll look into it. It would certainly be easier than what I'm trying to do.<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jun 18, 2018, at 18:09, Oleg Antonov <<a href="mailto:oleg.a@pinstudio.ru" class="">oleg.a@pinstudio.ru</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Why don't you store primary contact in custom field (UItype 10) in the organization?<div class="gmail_extra"><div class=""><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class=""><div class=""><div class=""><br class=""></div></div></div></div></div>
<br class=""><div class="gmail_quote">2018-06-19 0:05 GMT+03:00 Alex Hall <span dir="ltr" class=""><<a href="mailto:ahall@autodist.com" target="_blank" class="">ahall@autodist.com</a>></span>:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="">Thanks, but that's not quite what I'm going for. I want to run this function each time a contact is updated, changing it to be primary if the custom field was checked and removing its status as primary if the box was unchecked. Where my function comes in is in making sure that, upon becoming primary, any other contacts assigned to this user are removed as primary. Essentially, this custom field is being forced to be a single field shared by all contacts of an organization, where only one contact can have the field checked at a time.</div><div class=""><br class=""></div><div class="">I therefore need to get from the entity passed to the function, to its sibling contacts. I also need the status of the "primary" custom field to know if I have to change anything. If I do, I have to set "primary" to false in all other contacts that belong to the same organization as the one represented by the entity, then set the entity's "primary" to true.<br class=""></div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Jun 18, 2018 at 4:17 PM, Christoper J Combrink <span dir="ltr" class=""><<a href="mailto:christopher@wowfingers.com" target="_blank" class="">christopher@wowfingers.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto" class="">It's really late.. But I may have a solution that goes about a totally different way. <div dir="auto" class=""><br class=""></div><div dir="auto" class="">If I understand your logic - you could query all contracts into an array that are "related to" an organisation and then mark the most recently created one as the primary contact. Assuming you always want to have the most recent one set as primary? <br class=""><br class=""><div data-smartmail="gmail_signature" dir="auto" class="">Regards,<br class=""><br class="">CJC<br class=""><br class="">(sent on the move)</div></div></div><br class=""><div class="gmail_quote"><div class=""><div class="m_2605414889420708377h5"><div dir="ltr" class="">On Mon, 18 Jun 2018, 21:45 Alex Hall, <<a href="mailto:ahall@autodist.com" target="_blank" class="">ahall@autodist.com</a>> wrote:<br class=""></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><div class="m_2605414889420708377h5"><div dir="ltr" class=""><div class="">Hello list,</div><div class="">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:</div><div class=""><br class=""></div><div class="">* get $entity's "is primary" custom field value</div><div class="">* exit if the newly set value is false, as there's nothing to update</div><div class="">* get $entity's parent organization (remember that $entity is from a contacts workflow)</div><div class="">* set all the children contacts of $entity's parent organization to not be primary, while setting $entity itself to be the only primary</div><div class=""><br class=""></div><div class="">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.<span class="HOEnZb"><font color="#888888" class=""><br class=""></font></span></div><span class="HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">-- <br class=""><div class="m_2605414889420708377m_7311429641083417211m_463440088625530483gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class=""><div class=""><div class="">Alex Hall<br class=""></div>Automatic Distributors, IT department<br class=""></div><a href="mailto:ahall@autodist.com" rel="noreferrer" target="_blank" class="">ahall@autodist.com</a><br class=""></div></div>
</div></font></span></div></div></div><span class="HOEnZb"><font color="#888888" class="">
______________________________<wbr class="">_________________<br class="">
<a href="http://www.vtiger.com/" rel="noreferrer noreferrer" target="_blank" class="">http://www.vtiger.com/</a></font></span></blockquote></div><span class="HOEnZb"><font color="#888888" class="">
<br class="">______________________________<wbr class="">_________________<br class="">
<a href="http://www.vtiger.com/" rel="noreferrer" target="_blank" class="">http://www.vtiger.com/</a><br class=""></font></span></blockquote></div><span class="HOEnZb"><font color="#888888" class=""><br class=""><br clear="all" class=""><br class="">-- <br class=""><div class="m_2605414889420708377gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class=""><div class=""><div class="">Alex Hall<br class=""></div>Automatic Distributors, IT department<br class=""></div><a href="mailto:ahall@autodist.com" target="_blank" class="">ahall@autodist.com</a><br class=""></div></div>
</font></span></div>
<br class="">______________________________<wbr class="">_________________<br class="">
<a href="http://www.vtiger.com/" rel="noreferrer" target="_blank" class="">http://www.vtiger.com/</a><br class=""></blockquote></div><br class=""></div></div>
_______________________________________________<br class=""><a href="http://www.vtiger.com/" class="">http://www.vtiger.com/</a></div></blockquote></div><br class=""></body></html>