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

Discussion

Discussion

Workflow Parameters are NOT Tokens for Scripts that call GetToken

SDK
posted on May 5, 2022 Show version history

I have discovered that workflow parameters are not the same as tokens in a workflow when it comes to using them in a SDK Script.  Worse than that, in the script editor, GetToken works fine to get values that are parameters into the script but when run in the workflow server, the workflow parameters are not fetchable by the SDK Script.  The error messages that show are related to the invalid string values that arrive in your script.  If you are passing a SQL WHERE clause, then the SQL statement will not be composed correctly from the GetToken(parameter value).

Tokens need to be created in the workflow and their values can be set using the parameter values to work around this.  Some documentation could include clarification and a warning for those of use that spend days trying to find out why a script runs fine in the editor but fails to get the token values when they are workflow parameters.

Arggh.

1 0
replied on May 6, 2022

Can you post a code sample? What version of Workflow are you using?

GetTokenValue("param name here") correctly resolves the input parameter for me.

0 0
replied on May 6, 2022

Attached here for you.  The GetTokenValue calls do not work for parameters to the containing workflow in Version 11.

They work for tokens and you can assign the parameter value to a token and then the GetTokenValue will get a valid string.  All these are string values.

When it does not work, you will have your C# code fail with the invalid string contents in whatever context it fails.  String values for parameters may be found as "System.String[]", for example.

0 0
replied on May 6, 2022 Show version history

Ian,

Input parameters are tokens, but they are multi-value tokens.

In order for them to be dynamic/custom they kind of all have to be multi-value as far as the underlying object is concerned for multi-value to be an option.

As a result, you either have to do as mentioned:

A) Store them to an interim token

B) Treat them like an array when using GetTokenValue

You'd run into the same thing if you tried to use GetTokenValue with a multivalue Token created within the workflow.

Workflow Input Parameters in Script Activity - Laserfiche Answers

1 0
replied on May 6, 2022

So that is good to know.  It suggests that the window for creating workflow parameters should not have a Multi-Value option but should have a note to developers that they are all multi-valued.

I accept your explanation without understanding why they all need to be multivalued.

 

0 0
replied on May 6, 2022

Well the checkbox is for Workflow Designer itself because it handles the values differently and accepts inputs from other workflows differently when it is labeled as a multi-value token.

The reason it behaves differently in a script is that in a script you're bypassing that extra layer/UI that handles all that so you just get the underlying object.

It's similar to the type Tags you put on a Token. In the designer a Boolean token can evaluate true/false, a number can be greater than/less than, etc.

When you dig into those same tokens in a script you're bypassing that and getting the underlying object so even a text token needs .ToString().

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

Sign in to reply to this post.