简体   繁体   English

NetSuite Case 语句在保存的搜索中有效,但在工作流中无效

[英]NetSuite Case statement works in Saved Search but doesn't work in Workflow

I have an issue with a formula case statement in a NetSuite workflow, I am using the same case statement in a saved search and it works just fine, but generates an error in the workflow formula for sourcing date, to set the date field on a cashsale record created from a sales order.我在 NetSuite 工作流中使用公式案例语句有问题,我在保存的搜索中使用相同的案例语句并且它工作正常,但在采购日期的工作流公式中生成错误,以将日期字段设置为从销售订单创建的现金销售记录。

NetSuite formula which basically states if it is 10:00 PM (22:00) or after increment by one day, otherwise use datecreated date. NetSuite 公式基本上说明是晚上 10:00(22:00)还是在增加一天之后,否则使用 datecreated 日期。 (this is used to calculate settlement date for banking reconciliation matching) (这用于计算银行对账匹配的结算日期)

The workflow event is "Before Record Load" on "Create" a Cashsale record which is definitely a server-side event.工作流事件是“创建”现金销售记录上的“记录加载前”,这绝对是服务器端事件。 I have also independently pulled out我也独立退出了

to_date({createdfrom.datecreated}) + 1

and

{createdfrom.datecreated}

Which work independently as expected without errors, really not sure what I am doing wrong哪个按预期独立工作没有错误,真的不确定我做错了什么

CASE WHEN to_number(to_char({createdfrom.datecreated}, 'HH24')) >= 22 THEN to_date({createdfrom.datecreated}) + 1 ELSE {createdfrom.datecreated} END

Here is the case statement I used in my saved search which works perfectly这是我在保存的搜索中使用的案例陈述,效果很好

CASE WHEN to_number(to_char({datecreated}, 'HH24')) >= 22 THEN to_char(({datecreated} + 1), 'DD/MM/YYYY') ELSE to_char(({datecreated}), 'DD/MM/YYYY') END

so basically in a before load create record user event use:所以基本上在加载之前创建记录用户事件使用:

CASE WHEN to_number(to_char({sysdate}, 'HH24')) >= 22 THEN {sysdate} + 1 ELSE {sysdate} END

I see you have clarified your question.我看到你已经澄清了你的问题。

{trandate} is a date field while the formula is producing a datetime field {trandate}是日期字段,而公式正在生成日期时间字段

So since your formula is meant to populate a date field you have to convert the datetime to a date:因此,由于您的公式旨在填充日期字段,因此您必须将日期时间转换为日期:

TRUNC(CASE WHEN to_number(to_char({createdfrom.datecreated}, 'HH24')) >= 22 THEN {createdfrom.datecreated} + 1 ELSE {createdfrom.datecreated} END)

Unfortunately Netsuite Workflow formula value is not reliable in terms of using the Netsuite formulas that run in saved search.不幸的是,就使用在已保存搜索中运行的 Netsuite 公式而言,Netsuite Workflow 公式值并不可靠。 Some work and some don't.有些工作,有些不工作。 In this case the To_char and date formatting seems to be not recognized at all.在这种情况下,To_char 和日期格式似乎根本无法识别。

Solution is a custom field named “Created Hours” that is dynamically sourcing value from a saved search.解决方案是一个名为“创建时间”的自定义字段,它从保存的搜索中动态获取价值。 The field is exposed in Sales Order and Cash Sale transaction form (You can hide it as well).该字段在销售订单和现金销售交易表单中公开(您也可以隐藏它)。 I then use the field as my comparison to achieve the condition that will set the date value.然后我使用该字段作为我的比较来实现将设置日期值的条件。 I tested few old Sales orders converting to Cash Sales and works well我测试了几个旧的销售订单转换为现金销售并且运作良好

Custom field hours自定义字段小时

Hours saved search小时保存搜索

Workflow to evaluate hours评估小时数的工作流

Hope this helps other people with the same or similar issues.希望这可以帮助其他有相同或相似问题的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM