salesforce - 是否有适用于 ELSE 函数的行计数计数函数?
问题描述
我有一个代码应该显示凭证详细信息。如果没有凭证,则应显示任何内容。我们使用 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>
解决方案
您可以通过先将值分配给变量然后引用该临时变量来解决此问题。尝试更改您的代码以执行以下操作:
SET @rowcount = RowCount(@voucherRows)
IF @rowcount >= 1 THEN
这应该可以解决问题。如果没有,您可以简单地使用该ISNULL
功能。
推荐阅读
- twitter-bootstrap - 无法更改工具提示的背景颜色
- javascript - React.js 应用程序向 Django 后端发送请求时出现 CORS 问题
- codeigniter-3 - 遇到未捕获的异常,类型:RuntimeException
- jsviews - Jsviews树控件展开后引发第二次点击事件
- vb.net - System.StackOverflowException 在我的 VB.NET 测验中发生在哪里?
- typescript - Cookie 设置/读取无法始终如一地工作(第一个有效,第二个无效)
- java - 如何在没有登录和 cli 的情况下在 Aws ec2 上运行 .Jar 文件?
- javascript - IBM Cloud Function 不产生任何输出
- azure-devops - Azure DevOps - 发布管道 - 部署后执行测试
- javascript - 如何修复“TypeError:无法设置属性 'width' of null”?