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

Question

Question

Condition to Check Count of Values in Multi-Value Token

asked on July 1, 2014

I would like to have a condition on a routing decision to check the count of how many values exist in a multi-value token. I understand I can loop through the values to get a count but I am hoping there is a way just to see a count of how many values their are. Anyone find a way to get the count of values in a multi-value token without looping through each one or using the pattern matching activity?

2 0

Answers

APPROVED ANSWER
replied on July 3, 2014

Conditions on multi-value tokens do not just check the first value. If you put a condition on a multi-value token of "equals" it will check that any value in the token equals that value. If you put a condition on "contains" it will check that any value contains your input.

 

You should be able to just check that your token contains "Error" and that would be sufficient, it will check all the values.

1 0
SELECTED ANSWER
replied on July 3, 2014

Glad to help, have a great 4th!

0 0

Replies

replied on July 1, 2014

You can use token functions to get the count of values in a multi-value token. Set this to another token and use it in conditions.

0 0
replied on July 2, 2014

There are a bunch of ways I can get the count but I am hoping that the count will become something we can reference directly.  Thus I could have a conditional statement that says %token COUNT equals 2 or %token COUNT is greater than 1.  Even better would be if we could also have it use contains to check all values (not just the first) or a specified nth value.

0 0
replied on July 3, 2014

You'll want to do what Miruna is saying. Create a "Count" token with assign token value and give it the value of the "Value Count" token function of the token in question. I'm not sure what you mean by having a multivalue and checking contains, do you want 1 count token with multiple different other tokens' counts inside it? Then you would create a multivalue token and append each count. See below on creating the token.

 

0 0
replied on July 3, 2014

At this point I understand that Workflow will not do specifically what I am wanting without having create additional tokens or loop through values.  What I am hoping will be in a future version will be that a condition statement can:

  1. Directly check the count of a token without having to create a second token to hold the count value of the first token (seems like overkill when conditions should be able to access that info directly)
  2. Check all values (or specific nth values) to see if they match the condition (equals, contains, is in, matches regular expression, ...).  Currently the condition statement only checks the first value in a multi-value token unless you loop through the values.

 

To give you my use case.  I have a multi-value token that I put in everything Workflow does to a document (moved to, renamed to, filled fields, created shortcuts, ...). At the beginning I write the initiator and trigger into the first value.  Then I check for errors and if I find any I write it into the second value.  Thus I want to see if the token has more than 1 value (meaning it errored) before I move onto the next portion where I actually work with the document.  Later I check a database lookup and write the error into the multivalue field.  Thus I want to be able to check if the word "ERROR" ever shows up in any values without having to loop through them.

 

I understand I can create a token "Status" that I change to error if there is one and that I can create another token to store the count.  What I am hoping is that the condition statements start being able to work directly with all values of a multi-value token without taking these extra steps.  

1 0
APPROVED ANSWER
replied on July 3, 2014

Conditions on multi-value tokens do not just check the first value. If you put a condition on a multi-value token of "equals" it will check that any value in the token equals that value. If you put a condition on "contains" it will check that any value contains your input.

 

You should be able to just check that your token contains "Error" and that would be sufficient, it will check all the values.

1 0
replied on July 3, 2014

Awesome! I tried that initially and it didn't find it but I obviously messed something else up.  It just worked now in testing so that solves that problem. Thanks a ton for the help with my mistake!  I'd still like the ability to directly use the count of a mulit-value token in a condition statement (without having to use another token) but that's a wish and not a need.

0 0
SELECTED ANSWER
replied on July 3, 2014

Glad to help, have a great 4th!

0 0
replied on August 4, 2014

With WF 9.1.1 I just tried to use a conditional statement to check if a multi-value token "does not contain" a value and it always came back true even though the multi-value token did contain the value.  I then tried it with a "does contain" on the same token and that also came back true.  To get around this I set this condition to see if it does contain the value and only run if false.  The issue appears to be that "does not contain" does not check all of the values within a multi-value token.

0 0
replied on August 4, 2014

"does not contain X" on a multi-value token is treated as "is there a value that does not contain X".  Expanding the conditions to set operations is on our to-do list, but we don't have a release date yet.

0 0
replied on August 4, 2014

I hadn't thought of using it that way but I like that flexibility.  Thanks for the heads up!

0 0
replied on October 1, 2014

Following on Matt Ross comment, checking a multivalue token using 'equal'  or 'contains'' will check all values and will return 'True' or 'False' depending if it finds it or not, can it also return a multi value token containing the indices of all values found?

0 0
replied on October 1, 2014

No, the condition checks until it finds a match, after that it doesn't check the rest of the values. And it does not return tokens.

0 0
replied on July 11, 2014

If a response answered your question, please click "This answered my question" to let us know.

 

Thanks!

0 0
replied on July 11, 2014

Thanks for the reminder.  I was too exited to have a solution.

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

Sign in to reply to this post.