Page 1 of 1

Do not send tag if no data

Posted: Thu Oct 01, 2015 1:47 pm
by dhascup
Sending XML invoice to customer

if 1%60 net 61, we send the following:
<PaymentTerm payInNumberOfDays="60">
<Discount>
<DiscountPercent percent="1.000"/>
</Discount>
</PaymentTerm>
<PaymentTerm payInNumberOfDays="61"/>


if net 60, we currently send:
<PaymentTerm payInNumberOfDays="">
<Discount>
<DiscountPercent percent=""/>
</Discount>
</PaymentTerm>
<PaymentTerm payInNumberOfDays="60"/>


They are rejecting this and they want us to send:
<PaymentTerm payInNumberOfDays="60"/>


I tried using the SkipIfEmpty = true but receiving an error.

Linoma support told me : "you cannot use the Skip If Empty function with child elements and/or elements."

Thanks in advance for the help
David

Re: Do not send tag if no data

Posted: Thu Oct 01, 2015 2:26 pm
by Support_Rick
David,

What you were told by Support is correct ... if the element contains sub-elements or attributes, then the value for "skipIfEmpty" is ignored or not allowed.

In your code, you have:
Code: Select all
<element name="PaymentTerm">
	<attribute name="payInNumberOfDays" value="${dataHeader[41]}" />
	<element name="Discount">
		<element name="DiscountPercent">
			<attribute name="percent" value="${dataHeader[42]}" trim="both" />
		</element>
	</element>
</element>
"payInNumberOfDays" is an attribute of the element "PaymentTerm" that has sub-elements and attributes, which isn't allowed in that scenario by definition.

Your post also contains the following statement:
They are rejecting this and they want us to send:
<PaymentTerm payInNumberOfDays="60"/>
Which corresponds to this:
Code: Select all
<element name="PaymentTerm">
	<attribute name="payInNumberOfDays" value="${dataHeader[43]}" />
</element>
Which could utilize the option of ${system.emptyString} as the null substitute for the value so that it represents a "blank" if nothing is presented.