Question

How sync Email field in account section with communication options

Hello, I am trying to make the Email field in the account section synchronize in real-time with the main email field in the communication options. Could you help me with that? I have tried using the functionality with the SyncEntityWithCommunicationDatil method, but I haven't been able to achieve it.

Like 0

Like

2 comments

Hello,

Actually, synchronization for some fields is already implemented in the Account section, such as Fax, Phone, etc.

To set up similar synchronization for the email column, you need to do the following:

  1. Create a column named UsrEmail if it doesn't exist already, and select "Email address" as its type.

  2. Go to the Source Code page, and in the "attributes" block, add the following code:


 

....

attributes: {

            "UsrEmail": {

                "dependencies": [

                    {

                        "columns": ["Email"],

                        "methodName": "syncEntityWithCommunicationDetail"

                    }

                ]

            }

        },

.....

 

Replace "UsrEmail" with the code of your column that needs to be synchronized with the detail.

 

  1. Create an override for the AccountCommunicationDetail module with the following code:
define("AccountCommunicationDetail", ["AccountCommunicationDetailResources", "terrasoft", "Contact",
        "ConfigurationEnums", "ConfigurationConstants"], function(resources, Terrasoft, Contact, ConfigurationEnums,
        ConfigurationConstants) {
        return {
            methods: {
                initMasterDetailColumnMapping: function() {
                this.set("MasterDetailColumnMapping",[
                    {
                            "CommunicationType": ConfigurationConstants.CommunicationTypes.Email,
                            "MasterEntityColumn": "UsrEmail"
                    },
                    {
                        "CommunicationType": ConfigurationConstants.CommunicationTypes.MainPhone,
                        "MasterEntityColumn": "Phone"
                    },
                    {
                        "CommunicationType": ConfigurationConstants.CommunicationTypes.AdditionalPhone,
                        "MasterEntityColumn": "AdditionalPhone"
                    },
                    {
                        "CommunicationType": ConfigurationConstants.CommunicationTypes.Fax,
                        "MasterEntityColumn": "Fax"
                    },
                    {
                        "CommunicationType": ConfigurationConstants.CommunicationTypes.Web,
                        "MasterEntityColumn": "Web"
                    }
                ]);
            }
        }
    }
});

 

 

Again, replace "UsrEmail" with the code of your column that needs to be synchronized with the detail.

 

After these changes, when adding a communication means of type Email to the detail, the column "UsrEmail" will be populated with the same value.

 

4. For the logic of reverse synchronization, which would create a record in ContactCommunication, event logic is responsible. The process upon saving the contact is implemented in the CrtBase package, the Contact object, and the method "SynchronizeCommunication()" is called upon saving the record.

 

You can use these methods and create an analog for the Account object

.

I hope this helps you solve your task. Thank you for reaching out!

Thank you, was very useful

Show all comments