Use Private Data Key to populate Search field?

Post Reply
bdieckman
Newbie
Posts: 6
Joined: Wed Dec 06, 2023 3:34 pm

Use Private Data Key to populate Search field?

Post by bdieckman »

Hello.

Is it possible to use a private data key in the Search field of the "Define single-line text with variables" dialog? I think it should be possible but I can't seem to get the syntax right. Let's say I've stored a RegEx in a Job.PrivateData key "regularExpression" and I want to return the match in the Job.Name. I think that should look something like this:

[Job.Name:Search="[Job.PrivateData:Key="regularExpression"]"]

This gives the error:
Variable 'Job.Name' has incorrect syntax in 'Lookup value': unexpected 'r' character after the argument value; expected characters are ',' or ']'
Is this quote-related? The string is terminated prematurely in the second variable, causing everything after to be invalid.

Things I've tried:
  • Replaced the double-quotes around "regularExpression" with single quotes. This treats the whole variable as a literal.
  • Removed the quotes around the variable after "Search=". This gives an unexpected '[' error.
bdieckman
Newbie
Posts: 6
Joined: Wed Dec 06, 2023 3:34 pm

Re: Use Private Data Key to populate Search field?

Post by bdieckman »

This page in the manual suggests this should be possible in a Switch Calculation Expression...

https://www.enfocus.com/manuals/UserGui ... yntax.html
The Expression argument of the [Switch.Calculation] variable and the SQL arguments of Database variables can contain nested variables. These variables are used to define the value of the argument...
[Group.Variable:ArgumentName1="[Variable1]"]
Analogous to my use case would be to search for the Job.Name in the Job.Name. (This should return the job name.)

Entering this in the expression: [Job.Name:Search="[Job.Name]"] again treats the text in the quotes as a literal rather than populating the Variable. In the Calculation, the syntax ends up looking like this: [Switch.Calculation:Expression="[Job.Name:Search="[Job.Name]"]"] which of course returns 0 since it's a calculation...

I think I'm going to have to go back to the drawing board on this one.
freddyp
Advanced member
Posts: 1129
Joined: Thu Feb 09, 2012 3:53 pm

Re: Use Private Data Key to populate Search field?

Post by freddyp »

Is it possible to use a private data key in the Search field of the "Define single-line text with variables" dialog?
It is not. The Search field takes a regular expression, not a variable. I do not immediately see a use case for that regex being in a private data key, but you may gladly convince me otherwise.

What is the problem you are trying to solve?

The nested variables in a Switch.Calculation are nested inside Switch.Calculation, but not nested in themselves.
bdieckman
Newbie
Posts: 6
Joined: Wed Dec 06, 2023 3:34 pm

Re: Use Private Data Key to populate Search field?

Post by bdieckman »

Hi, Freddy. Thanks for the reply.

Our use case is that we have a list of products supported by our workflow, represented by a unique product key (it's shorthand, really... it doesn't conform to a single pattern, unfortunately) However, our file names are consistent enough that we can search the file name for the product key and decide how to route the incoming file by the matched value.

For instance, a regex like this: (SCCOV|HBCOV|SSPGS|PBPGS|HBPGS|ENDSHT|SPINEART|VARCOVART)
Would match "HBCOV" in the Job.Name: 12345A_HBCOV_884932.pdf
I would then store that match in a Job.PrivateData key for later routing.

This list changes frequently and I'd like to store the regex in an external file, retrieve it into a Job.PrivateData key and use it in multiple places in the workflow, rather than updating the regex in multiple flow elements each time the list changes.

I have a few other ideas, but I thought if the Search field could take a variable, it would be a slick solution for this particular challenge.

Happy to hear of any approach you might take for a similar challenge.

Thanks again!
freddyp
Advanced member
Posts: 1129
Joined: Thu Feb 09, 2012 3:53 pm

Re: Use Private Data Key to populate Search field?

Post by freddyp »

If the product key is always the second element after the first underscore you can use the StringSplitter app.
Post Reply