<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div name="messageBodySection">
<div dir="auto">Thanks for the reply, i would like for it to be in real time, and not after the record is saved.<br />
<br /></div>
</div>
<div name="messageSignatureSection"><br />
<div dir="auto">Emmanuele Maida</div>
</div>
<div name="messageReplySection">Il Apr 10, 2023, 10:15 AM +0200, Sutharsan J <ajstharsan@gmail.com> ha scritto:<br />
<blockquote type="cite">
<div dir="auto">Hi</div>
<div dir="auto"><br /></div>
<div dir="auto">Why can't you use workflow update field option  to auto fill account from parent account of selected contact?</div>
<div dir="auto"><br /></div>
<div dir="auto">If you use reference field such as uitype 10 for contact  and account it is possible </div>
<div dir="auto"><br /></div>
<div dir="auto">Thanks </div>
<div><br />
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Mon, 10 Apr 2023 at 03:10 Emmanuele Maida <<a href="mailto:emmanuele.maida@gmail.com">emmanuele.maida@gmail.com</a>> wrote:<br /></div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)">
<div dir="ltr">
<p style="margin:10px 0px;padding:0px;border:0px;outline:0px;font-size:14.3px;font-family:"lucida grande","Lucida Sans Unicode",tahoma,sans-serif;vertical-align:baseline;color:rgb(0,0,0)">Hello everyone,</p>
<p style="margin:10px 0px;padding:0px;border:0px;outline:0px;font-size:14.3px;font-family:"lucida grande","Lucida Sans Unicode",tahoma,sans-serif;vertical-align:baseline;color:rgb(0,0,0)">I'm currently working on customizing the Edit view of a custom module called "Pratiche" in Vtiger 7.5. The module has two related fields, contact_id and account_id. When a contact is selected, I want to automatically update the related account based on the selected contact's linked account.</p>
<p style="margin:10px 0px;padding:0px;border:0px;outline:0px;font-size:14.3px;font-family:"lucida grande","Lucida Sans Unicode",tahoma,sans-serif;vertical-align:baseline;color:rgb(0,0,0)">I have managed to update the account_id field value programmatically, but the display value of the related account field (account_id_display) does not update accordingly. The user has to refresh the page or to save to see the that the account has been correctly updated.</p>
<p style="margin:10px 0px;padding:0px;border:0px;outline:0px;font-size:14.3px;font-family:"lucida grande","Lucida Sans Unicode",tahoma,sans-serif;vertical-align:baseline;color:rgb(0,0,0)">Here's the relevant code from my Pratiche_Edit_Js file:<br />
<br /></p>
<div style="font-family:Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap;background-color:rgb(30,30,30);color:rgb(212,212,212)">
<div style="font-family:Consolas,"Courier New",monospace"><span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">updateAccountIdBasedOnContactId</span><span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">:</span> <span style="font-family:Consolas,"Courier New",monospace;color:rgb(86,156,214)">function</span> (<span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">container</span>) {</div>
<div style="font-family:Consolas,"Courier New",monospace">        <span style="font-family:Consolas,"Courier New",monospace;color:rgb(86,156,214)">var</span> <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">thisInstance</span> = <span style="font-family:Consolas,"Courier New",monospace;color:rgb(86,156,214)">this</span>;</div>
<div style="font-family:Consolas,"Courier New",monospace">        <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">container</span>.<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">find</span>(<span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">'input[name="contact_id"]'</span>).<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">on</span>(<span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">Vtiger_Edit_Js</span>.<span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">referenceSelectionEvent</span>, <span style="font-family:Consolas,"Courier New",monospace;color:rgb(86,156,214)">function</span> (<span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">e</span>, <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">data</span>) {</div>
<div style="font-family:Consolas,"Courier New",monospace">            <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">console</span>.<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">log</span>(<span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">"Contact selected:"</span>, <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">data</span>);</div>
<div style="font-family:Consolas,"Courier New",monospace">   </div>
<div style="font-family:Consolas,"Courier New",monospace">            <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">thisInstance</span>.<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">getRecordDetails</span>(<span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">data</span>).<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">then</span>(</div>
<div style="font-family:Consolas,"Courier New",monospace">                <span style="font-family:Consolas,"Courier New",monospace;color:rgb(86,156,214)">function</span> (<span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">response</span>) {</div>
<div style="font-family:Consolas,"Courier New",monospace">                    <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">console</span>.<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">log</span>(<span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">"Contact details:"</span>, <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">response</span>);</div>
<div style="font-family:Consolas,"Courier New",monospace">   </div>
<div style="font-family:Consolas,"Courier New",monospace">                    <span style="font-family:Consolas,"Courier New",monospace;color:rgb(86,156,214)">var</span> <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">accountId</span> = <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">response</span>[<span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">'data'</span>][<span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">'account_id'</span>];</div>
<div style="font-family:Consolas,"Courier New",monospace">                    <span style="font-family:Consolas,"Courier New",monospace;color:rgb(86,156,214)">var</span> <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">contactName</span> = <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">data</span>[<span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">'selectedName'</span>];</div>
<div style="font-family:Consolas,"Courier New",monospace">                    <span style="font-family:Consolas,"Courier New",monospace;color:rgb(86,156,214)">var</span> <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">message</span> = <span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">"Vuoi compilare i dati dell'azienda con quelli del contatto "</span> + <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">contactName</span> + <span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">" appena selezionato?"</span>;</div>
<div style="font-family:Consolas,"Courier New",monospace">   </div>
<div style="font-family:Consolas,"Courier New",monospace">                    <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">app</span>.<span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">helper</span>.<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">showConfirmationBox</span>({ <span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">'message'</span><span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">:</span> <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">message</span> }).<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">then</span>(<span style="font-family:Consolas,"Courier New",monospace;color:rgb(86,156,214)">function</span> (<span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">e</span>) {</div>
<div style="font-family:Consolas,"Courier New",monospace">                        <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">console</span>.<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">log</span>(<span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">"User confirmed"</span>);</div>
<div style="font-family:Consolas,"Courier New",monospace">   </div>
<div style="font-family:Consolas,"Courier New",monospace">                       </div>
<div style="font-family:Consolas,"Courier New",monospace">                        <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">container</span>.<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">find</span>(<span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">'input[name="account_id"]'</span>).<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">val</span>(<span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">accountId</span>).<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">trigger</span>(<span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">Vtiger_Edit_Js</span>.<span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">referenceSelectionEvent</span>, {</div>
<div style="font-family:Consolas,"Courier New",monospace">                            <span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">'source_module'</span><span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">:</span> <span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">'Accounts'</span>,</div>
<div style="font-family:Consolas,"Courier New",monospace">                            <span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">'record'</span><span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">:</span> <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">accountId</span></div>
<div style="font-family:Consolas,"Courier New",monospace">                        });</div>
<div style="font-family:Consolas,"Courier New",monospace">   </div>
<div style="font-family:Consolas,"Courier New",monospace">                        <span style="font-family:Consolas,"Courier New",monospace;color:rgb(106,153,85)">// Imposta il valore visualizzato del campo account</span></div>
<div style="font-family:Consolas,"Courier New",monospace">                        <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">container</span>.<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">find</span>(<span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">'input[name="account_id_display"]'</span>).<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">val</span>(<span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">response</span>[<span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">'data'</span>][<span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">'accountname'</span>]);</div>
<div style="font-family:Consolas,"Courier New",monospace">                       </div>
<br />
<div style="font-family:Consolas,"Courier New",monospace">   </div>
<div style="font-family:Consolas,"Courier New",monospace">                        <span style="font-family:Consolas,"Courier New",monospace;color:rgb(106,153,85)">// Ottieni i dettagli dell'azienda relazionata</span></div>
<div style="font-family:Consolas,"Courier New",monospace">                        <span style="font-family:Consolas,"Courier New",monospace;color:rgb(86,156,214)">var</span> <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">accountData</span> = {</div>
<div style="font-family:Consolas,"Courier New",monospace">                            <span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">'source_module'</span><span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">:</span> <span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">'Accounts'</span>,</div>
<div style="font-family:Consolas,"Courier New",monospace">                            <span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">'record'</span><span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">:</span> <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">accountId</span> <span style="font-family:Consolas,"Courier New",monospace;color:rgb(106,153,85)">// Modifica qui</span></div>
<div style="font-family:Consolas,"Courier New",monospace">                        };</div>
<div style="font-family:Consolas,"Courier New",monospace">   </div>
<div style="font-family:Consolas,"Courier New",monospace">                        <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">thisInstance</span>.<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">getRecordDetails</span>(<span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">accountData</span>).<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">then</span>(</div>
<div style="font-family:Consolas,"Courier New",monospace">                            <span style="font-family:Consolas,"Courier New",monospace;color:rgb(86,156,214)">function</span> (<span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">accountDetails</span>) {</div>
<div style="font-family:Consolas,"Courier New",monospace">                                <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">console</span>.<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">log</span>(<span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">"Account details:"</span>, <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">accountDetails</span>);</div>
<div style="font-family:Consolas,"Courier New",monospace">   </div>
<div style="font-family:Consolas,"Courier New",monospace">                                <span style="font-family:Consolas,"Courier New",monospace;color:rgb(106,153,85)">// Qui puoi utilizzare i dettagli dell'azienda per compilare altri campi</span></div>
<div style="font-family:Consolas,"Courier New",monospace">                                <span style="font-family:Consolas,"Courier New",monospace;color:rgb(106,153,85)">// ad esempio: container.find('input[name="custom_field"]').val(accountDetails['data']['custom_field']);</span></div>
<div style="font-family:Consolas,"Courier New",monospace">   </div>
<div style="font-family:Consolas,"Courier New",monospace">                            },</div>
<div style="font-family:Consolas,"Courier New",monospace">                            <span style="font-family:Consolas,"Courier New",monospace;color:rgb(86,156,214)">function</span> (<span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">accountError</span>, <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">accountErr</span>) {</div>
<div style="font-family:Consolas,"Courier New",monospace">                                <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">console</span>.<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">log</span>(<span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">"Error retrieving account details:"</span>, <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">accountError</span>, <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">accountErr</span>);</div>
<div style="font-family:Consolas,"Courier New",monospace">                            }</div>
<div style="font-family:Consolas,"Courier New",monospace">                        );</div>
<br />
<div style="font-family:Consolas,"Courier New",monospace">                        <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">container</span>.<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">find</span>(<span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">'input[name="account_id_display"]'</span>).<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">trigger</span>(<span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">'change'</span>);</div>
<div style="font-family:Consolas,"Courier New",monospace">                        <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">container</span>.<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">find</span>(<span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">'input[name="account_id"]'</span>).<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">trigger</span>(<span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">'change'</span>);</div>
<div style="font-family:Consolas,"Courier New",monospace">   </div>
<div style="font-family:Consolas,"Courier New",monospace">                    },</div>
<div style="font-family:Consolas,"Courier New",monospace">                        <span style="font-family:Consolas,"Courier New",monospace;color:rgb(86,156,214)">function</span> (<span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">error</span>, <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">err</span>) {</div>
<div style="font-family:Consolas,"Courier New",monospace">                            <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">console</span>.<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">log</span>(<span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">"User canceled"</span>);</div>
<div style="font-family:Consolas,"Courier New",monospace">                        });</div>
<div style="font-family:Consolas,"Courier New",monospace">                },</div>
<div style="font-family:Consolas,"Courier New",monospace">                <span style="font-family:Consolas,"Courier New",monospace;color:rgb(86,156,214)">function</span> (<span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">error</span>, <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">err</span>) {</div>
<div style="font-family:Consolas,"Courier New",monospace">                    <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">console</span>.<span style="font-family:Consolas,"Courier New",monospace;color:rgb(220,220,170)">log</span>(<span style="font-family:Consolas,"Courier New",monospace;color:rgb(206,145,120)">"Error retrieving contact details:"</span>, <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">error</span>, <span style="font-family:Consolas,"Courier New",monospace;color:rgb(156,220,254)">err</span>);</div>
<div style="font-family:Consolas,"Courier New",monospace">                }</div>
<div style="font-family:Consolas,"Courier New",monospace">            );</div>
<div style="font-family:Consolas,"Courier New",monospace">        });</div>
<div style="font-family:Consolas,"Courier New",monospace">    },</div>
</div>
<p style="margin:10px 0px;padding:0px;border:0px;outline:0px;font-size:14.3px;font-family:"lucida grande","Lucida Sans Unicode",tahoma,sans-serif;vertical-align:baseline;color:rgb(0,0,0)"><br />
<br />
<span style="font-size:14.3px;font-family:"lucida grande","Lucida Sans Unicode",tahoma,sans-serif">I have tried triggering the 'change' event on the account_id_display field, but it still doesn't update the display value. I am looking for a way to update the account display field in real-time so that the user can see the updated account name without refreshing the page.</span><br /></p>
<p style="margin:10px 0px;padding:0px;border:0px;outline:0px;font-size:14.3px;font-family:"lucida grande","Lucida Sans Unicode",tahoma,sans-serif;vertical-align:baseline;color:rgb(0,0,0)">Could someone please provide some guidance on how to achieve this?<br />
Are there any specific events or methods that I should be using to update the display value of the related account field programmatically?</p>
<p style="margin:10px 0px;padding:0px;border:0px;outline:0px;font-size:14.3px;font-family:"lucida grande","Lucida Sans Unicode",tahoma,sans-serif;vertical-align:baseline;color:rgb(0,0,0)">Any help would be greatly appreciated. Thank you!</p>
</div>
_______________________________________________<br />
<a href="http://www.vtiger.com/" rel="noreferrer" target="_blank">http://www.vtiger.com/</a></blockquote>
</div>
</div>
<span class="gmail_signature_prefix">--</span><br />
<div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr"><span style="color:rgb(102,102,102)">Development Manager<br />
Radus28 Software Solution<br /></span> <span style="color:rgb(102,102,102)"><img src="cid:part4.EAFD845F.485F57C8@radus28.com" title="www.radus28.com" alt="Radus28 Software Solution" width="205" height="60" /><br />
123, Level 2, Mc Larens Building<br />
Baudhaloka Mw.<br />
Colombo 04<br />
Sri Lanka<br />
M : +94773795291<br />
E  : <a href="mailto:sutharsan@radus28.com" target="_blank">sutharsan@radus28.com</a><br />
W : <a href="http://www.radus28.com" target="_blank">www.radus28.com</a></span></div>
</div>
_______________________________________________<br />
http://www.vtiger.com/<br /></blockquote>
</div>
</body>
</html>