You are viewing limited content. For full access, please sign in.

Question

Question

Text Value is Being Treated as Token

asked on June 19, 2020

Does anyone know how to escape text in Workflow that appears like a Token but is not?

I have a custom query that is querying the SQL Database, looking for any value that contains the text "(old)".  SQL statements use the operator LIKE and the symbol % as wildcards in order to find wildcard matches.

So my statement in my query looks like this:

WHERE [emp].[name_preferred] LIKE '%(old)%'

Unfortunately, Workflow is seeing %(old) as a token identifier.  I get a warning message that the token is not found, and then it returns all database (sees to be matching everything as true).

When testing the query from the workflow editor, it works as expected, it's just during a live run that it causes issues.

The funny thing is that you don't even reference tokens this way inside the query.  You use a ? symbol in the query and then list the tokens that associated to the different ? symbols throughout the query.

0 0

Answer

SELECTED ANSWER
replied on June 19, 2020

Thank you @████████

It didn't work exactly as you laid out, but I was able to get it working like this:

WHERE [emp].[name_preferred] LIKE CONCAT(?, '(old)', ?)

And then setting the two ? values to be equal to %.

I had to do it within the CONCAT statement so that it would make the string '%(old)%' instead of trying to do ''%'(old)'%'' because those values coming in through the ? symbols automatically include the surrounding ' symbols.

0 0

Replies

replied on June 19, 2020

Hi Matthew,

Try either of these solutions:

  • Try using ' / ' as an escape character. So instead of ' %(old)% ' it'd be ' /%(old)/% '
  • You can make a token with the percent sign in it (I'll call it Percent), and then for the query do the following: %(Percent)(old)%(Percent)
1 0
replied on June 12, 2024 Show version history

This Regex will find the "%" character of the beginning and then capture the rest of the value:

 

^\%(.+)

 

Meaning - starts with %, take everything after. Now the text will be treated like text and not a token. "%(Barcode 1)" becomes (Barcode 1).

 

In our case, Quick Fields was missing bar codes, sending in a value of "%(Barcode 1)".  That in turn was causing all kinds of other problems, like a Missing Token warnings.

replied on June 12, 2024 Show version history

We had a similar issue, where Quick Fields was passing in a field value of "%(Barcode 1)" whenever it missed a bar code.  We wanted to detect these documents and send them to a corrections queue. But, every task interpreted the string value as a token and then complained, "Token %(Barcode 1) not found.

We solved this with a simple script - simple, after many hours of "shoot me now" moments.

 

            Dim x = "RetrieveFieldValues_Shipping Number"
            x = x.replace("%", "")
            If x.ToString.Contains ("Barcode") Then
                SetTokenValue("Clean Token", "Barcode")
            End If 

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.