<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div name="messageBodySection">
<div dir="auto">Thanks for your reply, i tried with this: <br />
<br />
container.find('input[name="account_id"]').val(accountId).trigger(Vtiger_Edit_Js.referenceSelectionEvent, {<br />
'source_module': 'Accounts',<br />
'record': accountId<br />
}).trigger('SaveAjax', {<br />
'record': accountId,<br />
'value': response['data']['accountname']<br />
});<br />
<br />
But it doesn't work..<br /></div>
</div>
<div name="messageSignatureSection"><br />
Emmanuele Maida</div>
<div name="messageReplySection">Il Apr 11, 2023, 4:16 PM +0200, Alan Lord <alanslists@gmail.com> ha scritto:<br />
<blockquote type="cite">As I recall, you will need to update the uimeta object in the dom<br />
possibly via the SaveAjax action?<br />
<br />
HTH<br />
<br />
Al<br />
<br />
On 09/04/2023 22:38, Emmanuele Maida wrote:<br />
<blockquote type="cite" style="border-left-color: grey; border-left-width: thin; border-left-style: solid; margin: 5px 5px;padding-left: 10px;">Hello everyone,<br />
<br />
I'm currently working on customizing the Edit view of a custom module<br />
called "Pratiche" in Vtiger 7.5. The module has two related fields,<br />
contact_id and account_id. When a contact is selected, I want to<br />
automatically update the related account based on the selected contact's<br />
linked account.<br />
<br />
I have managed to update the account_id field value programmatically,<br />
but the display value of the related account field (account_id_display)<br />
does not update accordingly. The user has to refresh the page or to save<br />
to see the that the account has been correctly updated.<br />
<br />
Here's the relevant code from my Pratiche_Edit_Js file:<br />
<br />
updateAccountIdBasedOnContactId: function (container) {<br />
var thisInstance = this;<br />
container.find('input[name="contact_id"]').on(Vtiger_Edit_Js.referenceSelectionEvent, function (e, data) {<br />
console.log("Contact selected:", data);<br />
thisInstance.getRecordDetails(data).then(<br />
function (response) {<br />
console.log("Contact details:", response);<br />
var accountId = response['data']['account_id'];<br />
var contactName = data['selectedName'];<br />
var message = "Vuoi compilare i dati dell'azienda con quelli del<br />
contatto " + contactName + " appena selezionato?";<br />
app.helper.showConfirmationBox({ 'message': message }).then(function (e) {<br />
console.log("User confirmed");<br />
container.find('input[name="account_id"]').val(accountId).trigger(Vtiger_Edit_Js.referenceSelectionEvent, {<br />
'source_module': 'Accounts',<br />
'record': accountId<br />
});<br />
// Imposta il valore visualizzato del campo account<br />
container.find('input[name="account_id_display"]').val(response['data']['accountname']);<br />
<br />
// Ottieni i dettagli dell'azienda relazionata<br />
var accountData = {<br />
'source_module': 'Accounts',<br />
'record': accountId // Modifica qui<br />
};<br />
thisInstance.getRecordDetails(accountData).then(<br />
function (accountDetails) {<br />
console.log("Account details:", accountDetails);<br />
// Qui puoi utilizzare i dettagli dell'azienda per compilare altri campi<br />
// ad esempio:<br />
container.find('input[name="custom_field"]').val(accountDetails['data']['custom_field']);<br />
},<br />
function (accountError, accountErr) {<br />
console.log("Error retrieving account details:", accountError, accountErr);<br />
}<br />
);<br />
<br />
container.find('input[name="account_id_display"]').trigger('change');<br />
container.find('input[name="account_id"]').trigger('change');<br />
},<br />
function (error, err) {<br />
console.log("User canceled");<br />
});<br />
},<br />
function (error, err) {<br />
console.log("Error retrieving contact details:", error, err);<br />
}<br />
);<br />
});<br />
},<br />
<br />
<br />
<br />
I have tried triggering the 'change' event on the account_id_display<br />
field, but it still doesn't update the display value. I am looking for a<br />
way to update the account display field in real-time so that the user<br />
can see the updated account name without refreshing the page.<br />
<br />
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<br />
update the display value of the related account field programmatically?<br />
<br />
Any help would be greatly appreciated. Thank you!<br />
<br />
<br />
_______________________________________________<br />
http://www.vtiger.com/<br /></blockquote>
<br />
<br />
_______________________________________________<br />
http://www.vtiger.com/</blockquote>
</div>
</body>
</html>