Custom fields are commonly used in SugarCRM to allow handling custom type of data. Simple example is Middle Name field that is available in the Exchange and missing in the SugarCRM. Below we are going to demonstrate how to enable middle name synchronization.

Solution

AESync is able to use custom fields in the synchronization.

We assume that custom field is called middle_c (name of database column). This field is added to Contacts and Leads module:

Step 1: Add Field Definition

Synchronizer should be told that there is a field middle_c in the module Contacts and Leads. To explain this field definition to the synchronizer one needs to go to c:\ProgramData\GrinMark\AESync\Templates\syncdefs. and create a file Sugar.Middle.xml. Open it in the text editor, add:


<?xml version="1.0"?>
<RepositoryInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Modules>
    <ModuleInfo name="Contacts" adapterType="SugarSoapCommon.SugarAdapter" localizedName="Contacts">
      <Fields>
        <Text name="middle_c"/>
      </Fields>
    </ModuleInfo>
    <ModuleInfo name="Leads" adapterType="SugarSoapCommon.SugarAdapter" localizedName="Leads">
      <Fields>
        <Text name="middle_c"/>
      </Fields>
    </ModuleInfo>
  </Modules>
</RepositoryInfo>

Now do the same to explain Exchange field: create file named Exchange.Middle.xml. Open it in the text editor, add:


<?xml version="1.0"?>
<RepositoryInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Modules>
    <ModuleInfo name="Contacts" localizedName="Contacts">
      <Fields>
        <Text name="MiddleName" localizedName="Middle Name" displayOnly="false" />
      </Fields>
    </ModuleInfo>
  </Modules>
</RepositoryInfo>

Step 2: Update Synchronization Rules

Go to the folder: c:\ProgramData\GrinMark\AESync\Templates\syncdefs. Create file ExchangeConversionInfo.Middle.xml in the text editor. Define conversion rules to synchronizer field SugarCRM field middle_c with


<?xml version="1.0"?>
<ConversionInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <moduleConversion>
    <!-- Contacts -->
    <ConversionRules ForModule="Contacts" ToModule="Contacts" Description="Sugar2Exchange" Action="SynchContactsS2E" CodeNamespaces="ExchangeAdapter">
      <FieldRule Name="MiddleName"><rule xsi:type="CopyRule" Src="middle_c" /></FieldRule>
    </ConversionRules>
    <ConversionRules ForModule="Contacts" ToModule="Contacts" Description="Exchange2Sugar" Action="SynchContactsE2S">
      <FieldRule Name="middle_c"><rule xsi:type="CopyRule" Src="MiddleName" /></FieldRule>
    </ConversionRules>
    <!-- /Contacts -->
    <!-- Leads -->
    <ConversionRules ForModule="Leads" ToModule="Contacts" Description="Sugar2Exchange" Action="SynchLeadsS2E">
      <FieldRule Name="MiddleName"><rule xsi:type="CopyRule" Src="middle_c" /></FieldRule>
    </ConversionRules>
    <ConversionRules ForModule="Contacts" ToModule="Leads" Description="Exchange2Sugar" Action="SynchLeadsE2S">
      <FieldRule Name="middle_c"><rule xsi:type="CopyRule" Src="MiddleName" /></FieldRule>
    </ConversionRules>
    <!-- /Leads -->
  </moduleConversion>
</ConversionInfo>

Step 3: Re-Start the Synchronizer Service

Re-start the service for the new settings to take effect.

Quick Way

You may download sugar.middle.zip and unpack it in the c:\ProgramData\GrinMark\AESync\Templates\syncdefs folder.

Appendinx 1: Defining a Custom Field in SugarCRM

In this section we will show how to define custom field middle_c for the Leads module.

Log in as Administrator, and go to Admin section.

Go to Studio:

Choose Leads->Fields node and press Add Field button

Specify field name (in our case middle_c). Later this will be used in the synchronization settings to bind to this field. Set Display Label and, optionally, other field options. Finally press Save.

The field appears in the fields list:

It is also recommended (optionally) to show this field in the DetailView and EditView:

Finally, save and deploy new layouts:

The same procedure may be applied to Contacts module to add Middle Name field to it.