microsoft-dynamics - x++ 中的 strfmt 范围
问题描述
这个范围有什么问题?
rangeTransDate = strFmt('(("%1.%2" <= "%3" && "%3" == "%5") || ("%1.%4" > "%3"))',tableStr(CustomTable),fieldStr(CustomTable,TransDate), date2str(dateTo,321,2,0,2,0,4),fieldStr(CustomTable,SettlementDate),SysQuery::valueEmptyString());
我收到此错误:
查询扩展范围错误:位置 72 旁边应有右括号。
解决方案
AX 2012 文档的此页面仍然相关(我找不到 AX365 版本)。突出显示重要的部分给出:
创建查询范围值表达式的规则是:
- 将整个表达式括在括号中。
- 将所有子表达式括在括号中。
- 使用 X++ 中可用的关系和逻辑运算符。
- 仅使用范围数据源中的字段名称。
- 对查询中其他数据源的字段使用 dataSource.field 表示法。
这意味着 X++ 需要在每个比较运算符(也称为文档中的“子表达式”)周围加上大括号。你少了一些...
此外,使用该date2strxpp()
函数正确处理所有日期到字符串的转换。此函数可以通过将空日期值 ( dateNull()
) 转换为1900-01-01
. 我怀疑在其中放一个空字符串 ( SysQuery::valueEmptyString()
) 会起作用。
所以试试这个,注释的子表达式级别显示括号分组:
// subexpressions lvl 2: 4 4
// subexpressions lvl 1: |1 1 2 2 3 3|
// || | | | | ||
rangeTransDate = strFmt('(("%1.%2" <= "%3") && ("%3" == "%5") || ("%1.%4" > "%3"))',
tableStr(CustomTable),
fieldStr(CustomTable,TransDate),
date2strxpp(dateTo),
fieldStr(CustomTable,SettlementDate),
date2strxpp(dateNull()));
如果您在运行时仍然遇到类似的错误,请添加更多括号将每个子表达式成对分组:
// subexpressions lvl 3: 5 5
// subexpressions lvl 2: |4 4 3 3|
// subexpressions lvl 1: ||1 1 2 2| 3 3|
// ||| | | || | ||
rangeTransDate = strFmt('((("%1.%2" <= "%3") && ("%3" == "%5")) || ("%1.%4" > "%3"))',
tableStr(CustomTable),
fieldStr(CustomTable,TransDate),
date2strxpp(dateTo),
fieldStr(CustomTable,SettlementDate),
date2strxpp(dateNull()));
推荐阅读
- google-cloud-monitoring - 信用用完时停止 GCP 作业
- javascript - JS 数组在 Google Apps 脚本中未被识别为数组
- c# - C#手动停止异步for语句(打字机效果)
- javascript - reduce 可以返回一个包含 2 个值的数组吗?
- python - 线程超类 - args
- xml - XSLT 结合多个父母
- sql - SQL Server Query 等效于 excel 公式
- linux - 在 Ubuntu 20.04 上安装 codelite 时出错 - 无法启动连接
- node.js - 将 GIF 的所有帧显示为单个图像
- c++ - 如何在从抽象基派生的类中实现相同的方法?