Sync

The Sync action is used to synchronize a set of records in the Infor Public Sector database with the data in the import file. Records that exist in the XML but not the database will be added. Records that exist in both will be updated in the database to match the data in the import file. Records that exist in the database but not the XML will be deleted.

To select the records to be synchronized you must add a <Link> element to the step, with a ComparisonProperties attribute. Similar to the UpdateCheck attribute, ComparisonProperties specifies one or more of the step’s target properties in a comma-separated list. After mapping the data from the import file to the specified properties, the import processor loads the records that match those values and performs the sync.

The example below builds on the service request mapping shown in the previous section. After adding or updating a service request, the mapping will synchronize the customer calls associated with the request between the two data sources. Step 100, which adds or updates the service request, now has an output that maps the service request number to the ID SRNO.

<Steps RootQuery="/ServiceRequest">
   <Step Id="99" 
    TargetBusinessObject="Hansen.CRM.ServiceRequestType" 
    Action="Select">
      <Outputs>
         <Output Id="REQTYPE" Source="RequestTypeKey" />
      </Outputs>
      <Mappings>
         <Map Source="ServiceRequestType" Target="RequestType"/>
      </Mappings>
   </Step>
   <Step Id="100" 
    TargetBusinessObject="Hansen.CRM.ServiceRequest" Action="Create, Update" 
    UpdateCheck="ServiceRequestNumber">
      <Outputs>
         <Output Id="SRNO" Source="ServiceRequestNumber" />
      </Outputs>
      <Inputs>
         <Input VariableId="REQTYPE" Target="RequestType.RequestTypeKey" />
      </Inputs>
      <Mappings>
         <Map Source="ID" Target="ServiceRequestNumber" />
         <Map Source="CallInformation/TakenBy" Target="TakenBY.EmployeeID" />
      </Mappings>
   </Step>

Step 101 performs the sync. The TargetBusinessObject attribute identifies CustomerCall as the object to be synchronized. The step’s <Input> element maps the SRNO output from the previous step to the ServiceRequest.ServiceRequestNumber property of the CustomerCall object.

The step also has a <Link>element, which identifies step 101 as a child of step 100. For a Sync step, the ComparisonProperties attribute of the <Link> element specifies the property or properties you want to use to select the records to be synchronized. Each property in the list must be the target of an <Input> or <Map>. So this example will sync customer calls that match the request number of the service request.

   <Step Optional="true" Id="101" 
    TargetBusinessObject="Hansen.CRM.CustomerCall" Action="Sync" 
    UpdateCheck="Contact.ContactKey,ServiceRequest.ServiceRequestNumber" >
      <Link StepId="100" RelativeQuery="./CustomerCalls/CustomerCall" 
       ComparisonProperties="ServiceRequest.ServiceRequestNumber" />
      <Inputs>
         <Input VariableId="SRNO" Target="ServiceRequest.ServiceRequestNumber" />
      </Inputs>
      <Mappings>
         <Map Source="Contact/ID" Target="Contact.ContactKey" />
         <Map Source="IsPrimaryCaller" Target="IsPrimaryCaller"  />
         <Map Optional="true" Source="CallDateTime" Target="CallDateTime"  />
         <Map Optional="true" Source="Notes" Target="Comments"  />
      </Mappings>
   </Step>
</Steps>

Note that step 101 also has an UpdateCheck attribute, which is used to select the records that are to be updated. The ComparisonProperties attribute is first used to select a set of records to be synced, and UpdateCheck is then used to determine which of those records will be updated.

If records are to be deleted by a Sync step, the records are first queued and then deleted from bottom to top. Any data formatters in the mapping file are applied to the queue before the records are deleted.