我有一个代码应该显示凭证详细信息。如果没有凭证,则应显示任何内容。我们使用 RowCount > 0 但如果 Data Extension 中没有任何内容,RowCount 似乎不会返回 0。
如何更改 If 语句或 ELSE 语句。
%%[
SET @voucherXML = AttributeValue("Vouchers")
// build a rowset from the XML
SET @voucherRows = BUILDROWSETFROMXML(@voucherXML, "//voucher", 1)
SET @voucherNames = BUILDROWSETFROMXML(@voucherXML, "//voucher//name", 1)
SET @voucherAmounts = BUILDROWSETFROMXML(@voucherXML, "//voucher//amount", 1)
]%%
%%[If RowCount(@voucherRows) > 0 Then
FOR @index = 1 TO RowCount(@voucherRows) DO
// retrieve the items form the rowset from 1 to the count of rows
]%%
<p class="bdetails__bill__title" style="font-family: sans-serif; font-weight: 400; letter-spacing: 0.07em; line-height: 1.8em; Margin: 0; font-size: 11px;">
%%=FIELD(ROW(@voucherNames,@index),
"Value")=%%
</p>
<p class="bdetails__bill__value" style="font-family: sans-serif; font-size: 13px; font-weight: 400; letter-spacing: 0.07em; line-height: 1.8em; Margin: 0; text-align: right;">
-%%=FIELD(ROW(@voucherAmounts,@index),
"Value")=%%
</p>
<!--
%%[
NEXT @index
]%% -->
<!--%%[ELSE]%%-->
<h2 class="bdetails__title" style="color: #0b0b0b; font-family: sans-serif; font-weight: 600; line-height: 1.385em; Margin: 0; font-size: 24px; text-transform: uppercase; width: 100%; min-width: 100%; text-align: center;">
Bestelldetails
</h2>
<!--%%[ENDIF]%%
--> </p>