简体   繁体   English

Netsuite 保存的搜索中的 TRIM 或 REPLACE

[英]TRIM or REPLACE in Netsuite Saved Search

I've looked at lots of examples for TRIM and REPLACE on the internet and for some reason I keep getting errors when I try.我在互联网上查看了很多关于 TRIM 和 REPLACE 的示例,由于某种原因,我在尝试时不断出错。

I need to strip suffixes from my Netsuite item record names in a saved item search.我需要在保存的项目搜索中从我的 Netsuite 项目记录名称中去除后缀。 There are three possible suffixes: -T, -D, -S.有三种可能的后缀:-T、-D、-S。 So I need to turn 24335-D into 24335, and 24335-S into 24335, and 24335-T into 24335.所以我需要把24335-D变成24335,把24335-S变成24335,把24335-T变成24335。

Here's what I've tried and the errors I get:这是我尝试过的以及我得到的错误:

公式

结果

Can you help me please?你能帮我吗? Note: I can't assume a specific character length of the starting string.注意:我不能假设起始字符串的特定字符长度。

Use case: We already have a field on item records called Nickname with the suffixes stripped.用例:我们已经在项目记录上有一个名为 Nickname 的字段,去掉了后缀。 But I've ran into cases where Nickname is incorrect compared to Name.但是我遇到过昵称与名称相比不正确的情况。 Ex: Name is 24335-D but Nickname is 24331-D.例如:名字是 24335-D,但昵称是 24331-D。 I'm trying to build a saved search alert that tells me any time the Nickname does not equal suffix-stripped Name.我正在尝试构建一个已保存的搜索警报,该警报会在任何时候告诉我昵称不等于后缀剥离的名称。

PS: is there anywhere I can pay for quick a la carte Netsuite saved search questions like this? PS:我可以在任何地方支付快速点菜 Netsuite 保存的搜索问题吗? I feel bad relying on free technical internet advice but I greatly appreciate any help you can give me!依靠免费的互联网技术建议我感觉很糟糕,但我非常感谢你能给我的任何帮助!

You are including too much SQL - a formulae is like a single result field expression not a full statement so no FROM or AS.您包含太多 SQL - 公式就像单个结果字段表达式而不是完整语句,因此没有 FROM 或 AS。 There is another place to set the result column/field name.还有一个地方可以设置结果列/字段名。 One option here is Regex_replace() .这里的一个选项是Regex_replace()

REGEXP_REPLACE({name},'\-[TDS]$', '')

Regex meaning:正则表达式含义:

\-    : a literal -
[TDS] : one of T D or S
$     : end of line/string

To compare fields a Formulae (Numeric) using a CASE statement can be useful as it makes it easy to compare the result to a number in a filter.要比较字段,使用 CASE 语句的公式(数字)可能很有用,因为它可以很容易地将结果与过滤器中的数字进行比较。 A simple equal to 1 for example.例如一个简单的等于 1。

CASE WHEN {custitem_nickname} <> REGEXP_REPLACE({name},'\-[TDS]$', '') then 1 else 0 end

在保存的搜索中用作过滤条件的示例公式。

You are getting an error because TRIM can trim only one character: see oracle doc https://docs.oracle.com/javadb/10.8.3.0/ref/rreftrimfunc.html (last example). You are getting an error because TRIM can trim only one character: see oracle doc https://docs.oracle.com/javadb/10.8.3.0/ref/rreftrimfunc.html (last example).

So try using something like this所以尝试使用这样的东西

TRIM(TRAILING '-' FROM TRIM(TRAILING 'D' FROM {entityid}))

And always keep in mind that saved searches are running as Oracle SQL queries so Oracle SQL documentation can help you understand how to use the available functions. And always keep in mind that saved searches are running as Oracle SQL queries so Oracle SQL documentation can help you understand how to use the available functions.

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

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