【问题标题】:Netsuite custom formula field using a CASE statement with multiple WHEN conditions returning "invalid expression"使用具有多个 WHEN 条件的 CASE 语句返回“无效表达式”的 Netsuite 自定义公式字段
【发布时间】:2013-08-13 19:32:02
【问题描述】:

我对编写 NetSuite sql case 语句很陌生。我已经能够使用单个 WHEN 条件成功编写 CASE 语句,但是当我包含多个 WHEN 条件时,NetSuite 返回“无效表达式”错误。我想知道是否需要将 WHEN 条件与空格以外的其他内容分开。我见过具有多个 WHEN 条件的嵌套语句示例,但 NetSuite 不允许在公式字段中嵌套语句。这是我返回错误的语句:

CASE WHEN {item.custitem_custid} IN (05,12) 
THEN {amount}*{item.custitem_sharedat50} 
WHEN {item.custitem_custid} IN (37,42,76) 
THEN {amount}*0.02 ELSE {amount}*{item.custitem_sharedat33} 
END

这是我的 CASE 语句,其中包含一个有效的 WHEN 条件:

CASE WHEN {item.custitem_custid} IN (05,12) 
THEN {amount}*{item.custitem_sharedat50} 
ELSE {amount}*{item.custitem_sharedat33} END 

有 NetSuite 经验的人有什么想法吗?

【问题讨论】:

    标签: sql case netsuite


    【解决方案1】:

    您必须启动和终止每个 Case 语句

    CASE WHEN {item.custitem_custid} IN (05,12) 
      THEN {amount}*{item.custitem_sharedat50} 
    ELSE 
       CASE WHEN {item.custitem_custid} IN (37,42,76) 
          THEN {amount}*0.02 ELSE {amount}*{item.custitem_sharedat33} 
       END
    END
    

    这是我在有效的已保存搜索中使用的案例陈述

    CASE WHEN {classnohierarchy} = 'Snow' THEN 
       CASE WHEN {custbody_hdr_cs_status} IN ('Follow-up','Follow-up & Term') THEN 0 
       ELSE 
          CASE WHEN {shipstate} IN ('NV','NY','PA','SD','UT','VA','WY') THEN 1 
          ELSE 0 
          END 
       END 
    ELSE 0 
    END
    

    【讨论】:

      【解决方案2】:

      我也遇到了同样的问题。这似乎是系统中的一个错误。您应该向 NetSuite 提交支持请求。在解决此问题之前,请改用 DECODE。

      【讨论】:

        【解决方案3】:

        这是一个包含多个 when 的示例代码。它对我有用。

        var formula = "case  when {internalid} IN (10555) then 'a'"
                         + " when {internalid} IN (10556) then 'b'"
                         + " when {internalid} IN (10557) then 'c'"
                         + " else 'd' end";
        var filter = new nlobjSearchFilter('formulatext', null, 'contains', 'a').setFormula(formula);
        var searchResult = nlapiSearchRecord('salesorder', null, filter);
        

        你能告诉我们你得到的确切错误吗

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2018-06-11
          • 2018-04-30
          • 2022-08-17
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多