1

我对编写 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经验的人有什么想法吗?

4

3 回答 3

4

您必须启动和终止每个 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
于 2013-11-18T22:50:07.270 回答
0

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

于 2013-08-29T23:55:55.080 回答
0

这是一个带有多个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);

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

于 2013-09-04T08:00:10.623 回答