Example Invoice Data: Add a Table
This example adds a new complex type that contains contract charges for an invoice.
Activity Steps
- Add the Charge complex type to the XSD.Copy
<xs:element name="Charges" type="Charge" minOccurs="0" maxOccurs="unbounded"/>
<xs:complexType name="Charge">
<xs:sequence>
<xs:element name="OrderBy" type="xs:string"/>
<xs:element name="LineItem_Id" type="xs:string"/>
<xs:element name="ChargeType" type="xs:string"/>
<xs:element name="ChargeValueType" type="xs:string"/>
<xs:element name="Name" type="xs:string"/>
<xs:element name="BaseCharge" type="xs:decimal"/>
<xs:element name="PayableMetals" type="xs:decimal"/>
<xs:element name="TotalIncremental" type="xs:decimal"/>
<xs:element name="TotalDMT" type="xs:decimal"/>
<xs:element name="TotalInvoice" type="xs:decimal"/>
<xs:element name="Tiers" type="Tier" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType> - Refresh the connection in Crystal Reports so that the XSD update is available. See Invoice Data XSD.
- Add code to the invoice data XML script to append a Charges element to the LineItems node.
New field elements can be created and appended to the Charges node and populated as required.
CopyXmlNode charge = originalDocument.CreateElement("Charges");
nodeLineItem.AppendChild(charge);
XmlNode chargeType = originalDocument.CreateElement("ChargeType");
charge.AppendChild(chargeType);
chargeType.InnerText = "ContractCharge";