update Contact name using Custom Contact Button

lock
push_pin
done
Beantwortet
4

I have a Custom button linked to a CRMscript/Edit Contact that pops up up a dialog box to select a name based on whatever was first typed in the Name field, this works however then updating the contact name does not work. There is no Trigger that can be used for this scenario, please help    
 
I have tried:
ed.setOutputValue("ContactEntity.Name", "TEST");
getHtmlElement('Name').setValue("TEST");
ed.setNavigateTo("javascript:document.getElementById('Name').value = 'TEST';");
setVariable("url", "javascript:document.getElementById('Name').value = 'TEST';");
 

16. Okt. 2024 | 11:53 AM

Alle Antworten (4)

You need to save the contact using NSContactEntity.

NSContactAgent contactAgent;
NSContactEntity contactEntity = contactAgent.GetContactEntity(contactId);

contactEntity.SetName("contactNameHere");
contactEntity = contactAgent.SaveContactEntity(contactEntity);

// Refresh so change is immediately visible
ed.setNavigateTo("contact.main[refresh=true]")
16. Okt. 2024 | 12:02 PM
I would like to be able top avoid saving the new contact. is it possible to trigger the 'save' button on the form så that I would have a helper script in the before save trogger as that have access to setOutputValue.

or is it possible to fill in a new contact using cgi, so passing all the non saved fields into a fresh windows and that way avoiding a save?
16. Okt. 2024 | 05:41 PM

I'm not entirely sure what you want to achieve. But you could combine EventDataDialogDefinition and the before-save trigger on Company. Here you can get user-input, and use that with the EventData object.

17. Okt. 2024 | 09:35 AM

Hi Dan,

The statement "There is no Trigger that can be used for this scenario" is not entirely accurate. Knowing what we know so far, I will agree with Kasper. Use before save and you will get the same results you want to achieve. 

If we are missing some context as to why 'no trigger can be used...', please elaborate. 

Best regards.

17. Okt. 2024 | 10:24 AM

Antwort hinzufügen