Drilling down

There are two ways to drill down to related business objects in a linked step, depending on how the objects are related. If the objects are linked through a property of the step’s target business object, you can use the ParentProperty attribute of the <Link> element to specify that property.

For example, employee records in Infor Public Sector are managed by the Employee object, but employee contact information is managed by the Contact object. Employee records are linked to contact records by the Employee.Contact property, which specifies the contact key. To include contact information in an employee export, you can drill down to the Contact object by setting the ParentProperty attribute of the <Link> element, as shown below.

<DataExport Name="Employee" RootElement="Employee" TargetBusinessObject="Hansen.Resources.Employee">
   <Steps>
      <Step Id="1">
         <DataMappings>
            <DataMap Source="EmployeeID" Target="@ID" />
            <DataMap Source="Name" Target="Name" />
            <DataMap Source="HireDate" Target="Hired" />
            <DataMap Source="Department.Description" Target="Department" />
         </DataMappings>
      </Step>
      <Step Id="2" ElementName="Contact">
         <Link Id="1" StepId="1" ParentProperty="Contact" />
         <DataMappings>
            <DataMap Source="AddressLine1" Target="Address" />
            <DataMap Source="City" Target="City" />
            <DataMap Source="State" Target="State" />
            <DataMap Source="PostalCode" Target="ZIP" />
         </DataMappings>
      </Step>
   </Steps>
</DataExport>

The export processor will select the contact record that matches the contact key in the employee record, and export the specified properties from that record. The output is shown below.

<Employee ID="17748">
   <Name>Joe Smith</Name>
   <Hired>05/07/2012</Hired>
   <Department>Development</Department>
   <Contact>
      <Address>11000 Olson Drive</Address>
      <City>Rancho Cordova</City>
      <State>CA</State>
      <ZIP>95670</ZIP>
   </Contact>
</Employee>
Note: Although most business object properties correspond to specific database columns, the Employee.Name property in this example does not correspond to a NAME column in the EMPLOYEE table. The value of the Name property is set dynamically based on the associated contact identity record. See the API documentation in the Infor Public Sector Reference Guide for a complete list of properties defined for each object.

Some objects have properties that you can use to export collections. For example, the ServiceRequest object has a CustomerCalls property that you can use to export the collection of customer calls associated with a service request. You can use the API documents in the Infor Public Sector Reference Guide to look up these properties.

<Link Id="1" StepId="1" ParentProperty="CustomerCalls" />

The other option for drilling down is to use the TargetBusinessObject attribute of the <Link> element to specify the desired object, and use the LoadId attribute to select the correct records. By default, the export processor will select records where the primary key matches the value of the LoadId attribute. If the records are linked through a property other than the primary key, you can use the TargetProperty attribute to specify that property.

For example, the employee export mapping file that was shown previously could be written as shown below. Instead of using the ParentProperty attribute of the <Link> element to drill into the Contact object, this example uses the TargetBusinessObject attribute. Notice that there is a new <Variables> element in step 1, which assigns the contact key of the employee’s associated contact record to a variable called ContactKey. The ContactKey variable is then used for the LoadId attribute. This is the primary key for a contact record, so the TargetProperty attribute isn’t required.

<DataExport Name="Employee" RootElement="Employee" TargetBusinessObject="Hansen.Resources.Employee">
   <Steps>
      <Step Id="1">
         <DataMappings>
            <DataMap Source="EmployeeID" Target="@ID" />
            <DataMap Source="Name" Target="Name" />
            <DataMap Source="HireDate" Target="Hired" />
            <DataMap Source="Department.Description" Target="Department" />
         </DataMappings>
         <Variables>
            <Variable Name="ContactKey" Property="Contact.ContactKey" />
         </Variables>
      </Step>
      <Step Id="2" ElementName="Contact">
         <Link Id="1" 
          TargetBusinessObject="Hansen.Resources.Contact" 
          LoadId="{ContactKey}" />
         <DataMappings>
            <DataMap Source="AddressLine1" Target="Address" />
            <DataMap Source="City" Target="City" />
            <DataMap Source="State" Target="State" />
            <DataMap Source="PostalCode" Target="ZIP" />
         </DataMappings>
      </Step>
   </Steps>
</DataExport>

Of course, using the ParentProperty is simpler, but this is only possible if the objects are linked through a property of the step’s target business object. If they’re linked through a property of the object you’re drilling into, you must use the TargetBusinessObject and the LoadId.

If the TargetBusinessObject of a <Link> element is a collection, the export processor will loop through the collection.

<DataExport Name="StockArea" RootElement="StockArea" TargetBusinessObject="Hansen.Inventory.StockArea">
   <Steps>
      <Step Id="1">
         <DataMappings>
            <DataMap Source="StockArea" Target="@Name" />
         </DataMappings>
         <Variables>
            <Variable Name="StockAreaKey" Property="StockAreaKey" />
         </Variables>
      </Step>
      <Step Id="2" ElementName="Audit">
         <Link Id="1" StepId="1"  
          TargetBusinessObject="Hansen.Inventory.StockAuditCollection" 
          LoadId="{StockAreaKey}" TargetProperty="StockArea" />
         <DataMappings>
            <DataMap Source="AuditKey" Target="@AuditKey" />
            <DataMap Source="Status" Target="Status" />
            <DataMap Source="ScheduledDate" Target="ScheduledDate" />
            <DataMap Source="CalculatedQuantityAtAuditDateTime" 
             Target="CalculatedQuantity" />
            <DataMap Source="Comments" Target="Comments" />
         </DataMappings>
      </Step>
   </Steps>
</DataExport>