Export mapping

In an export mapping file, the business object to be exported and the root node of the XML output are defined in the root <DataExport> element. In the example below, the TargetBusinessObject attribute indicates that the WorkOrder object will be exported, and the RootElement attribute defines a root <WORKORDER> element for the output.

<DataExport Name="WOExport" 
 RootElement="WORKORDER" 
 TargetBusinessObject="Hansen.WorkManagement.WorkOrder">

The attributes and child elements of the <WORKORDER> element are defined in one or more steps. In most cases, the first step defines the attributes and children of the root XML node in the output.

Similar to the <Mappings> element in an import mapping file, the <DataMappings> element maps business object properties to XML elements and attributes. The Source attribute of each <DataMap> element identifies a property of the target business object, and the Target attribute maps that property to an element or attribute (identified by an @ symbol). The example below adds a Key attribute and two child nodes, <AssignedTo> and <Scheduled>, to the root node.

<DataExport Name="WOExport" 
 RootElement="WORKORDER" 
 TargetBusinessObject="Hansen.WorkManagement.WorkOrder">
   <Steps>
      <Step Id="1">
         <DataMappings>
            <DataMap Source="WorkOrderNumber" Target="@Key" />
            <DataMap Source="Activity" Target="Activity" />
            <DataMap Source="ScheduledDateTime" Target="Scheduled" />
         </DataMappings>
      </Step>
   </Steps>
</DataExport>

The output defined by the above mapping is shown below.

<WORKORDER Key="1004">
   <Activity>1003</Activity>
   <Scheduled>11/11/2017</Scheduled>
</WORKORDER >

The Source attribute of a <DataMap> element can also drill down to a child business object. In the example above, the <Activity> element identifies the work order’s activity by its activity key, because this is the value stored in the work order table. If you want to include the activity code in the output instead, you can drill down through the activity key to the ActivityCode property, as shown below.

<DataMap Source="Activity.ActivityCode" 
 Target="Activity" />

To add new XML nodes to the output, you can add additional steps. Each step has an optional ElementName attribute, which defines the node the step will add to the output. A step that doesn’t specify an element name defines attributes and children of the parent node, as in the previous example. You can have a single step with an element name, as shown below.

<Steps>
   <Step Id="1" ElementName="Info">
      <DataMappings>
         <DataMap Source="WorkOrderNumber" Target="@Key" />
         <DataMap Source="AssignedTo" Target="AssignedTo" />
         <DataMap Source="ScheduledDateTime" Target="Scheduled" />
      </DataMappings>
   </Step>
</Steps>

In this case the step adds an <Info> element as a child of the <WORKORDER> element.

<WORKORDER>
   <Info Key="1004">
      <AssignedTo>17748</AssignedTo>
      <Scheduled>11/11/2017</Scheduled>
   </Info>
</WORKORDER>

In the example below, the first step defines two attributes for the root <Part> element, and the second step defines a child <Information> element.

<DataExport Name="PartExport" 
 RootElement="Part" 
 TargetBusinessObject="Hansen.Inventory.PartCatalog">
   <Steps>
      <Step Id="1">
         <DataMappings>
            <DataMap Source="PartKey" Target="@PartKey" />
            <DataMap Source="PartNumber" Target="@PartNumber" />
         </DataMappings>
      </Step>
      <Step Id="2" ElementName="Information">
         <DataMappings>
            <DataMap Source="PartClassification.Code" 
             Target="Classification" />
            <DataMap Source="SubClass.Code" 
             Target="Subclassification" />
            <DataMap Source="IsStocked" Target="Stocked" />
         </DataMappings>
      </Step>
   </Steps>
</DataExport>

The output defined by the above mapping is shown below.

<Part PartKey="1001" PartNumber="">
   <Information>
      <Classification></Classification>
      <Subclassification></Subclassification>
      <Stocked></Stocked>
   </Information>
</Part>

You can also specify text() for the Target attribute of a <DataMap> element. In that case, rather than adding a new XML element, the export processor will add the source data as text of the parent element. For example, this step defines an <ns:Note> element with three attributes, and adds the comments from a log entry to the element's text:

<Step Id="3" ElementName="ns:Note">
   <Link Id="1" StepId="2" ParentProperty="Logs" />
   <DataMappings>
      <DataMap Source="PrimaryKey" Target="@noteID" />
      <DataMap Source="LogBy.EmployeeID" Target="@author" />
      <DataMap Source="LogStartDateTime" Target="@entryDateTime" />
      <DataMap Source="Comments" Target="text()" />
   </DataMappings> 
</Step> 

A sample output from the above step is shown below.

<ns:Note noteID="1026" author="LDOURLAY" 
 entryDateTime="2017-11-21T23:25:00">
    General comments.
</ns:Note>