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

Question

Question

Workflow Input Parameters in Script Activity

asked on April 19, 2018 Show version history

Several times now I've run into situation in which I wanted to use Input Parameters within a Workflow Script or SDK Script (Workflow 10.2), but for some reason the GetTokenValue() method doesn't seem to work as expected.

I usually work around this by putting the input parameter into a separate token and referencing that token in the script instead, but I figured it was time I mention it here to see if it might be a bug or if there is something I am missing.

From what I've seen, when I use GetTokenValue().ToString() on an Input Parameter, I always ended up with "System.String[]"

I tried the following instead:

string[] parameter = GetTokenValue("Test") as string[];
string test = parameter[0];

This seemed to work, but I'm hesitant to actually use this approach as it doesn't seem like intended behavior and my current workaround seems less likely to break if this ever changes.

Are Input Parameters meant to behave this way when using GetTokenValue?

1 0

Answer

SELECTED ANSWER
replied on October 3, 2018

Hello Jason, 

 

I've looked into it and it appears to be a bug when using the Default Value with an Input parameter. Thank you for bringing this to our attention.

Here is a bit of a workaround that I have done:

What I've done is use an Assign Token Value activity to modify the token with the same value which seems to give it the correct type. This is a bit safer since the index approach seems to fail when an invoke workflow calls that workflow with a given input parameter as it is a string that gets passed along rather than an string array which results in an Object ref error.

Hope this helps!

3 0

Replies

replied on April 20, 2018

I think your are handling this right. It appears that all input parameters are multi-value tokens which are stored in an object that can be converted to an array of strings. Likely this was done for simplification, now you can choose if the field accepts multiple values or not, but either way it is stored as the same token type.

2 0
replied on August 16, 2018 Show version history

I am having a similar problem and it is just baffling.  I have an input parameter named "StartingDocID", with the tags for Entry and Document only.  It represents an Entry ID passed in from another process.  It works fine in the Find Entry task. 

However I try to convert it to a string, here:

Dim sEntryName as String = GetTokenValue("StartingDocID").ToString

It gives me the error, Conversion of type String() to type Integer is not valid. I can add the String tag to StartingDocID, but that does not make a diffeence.  In the Token Dialog, I can select StartingDocID, but the Index property does not become enabled.  It's basically acting like an array, without presenting itself as an array.

Then I decided to follow the model above:

Dim sArray() As String = GetTokenValue("StartingDocID").ToString

Dim sEntryID as String = sArray(0)

This produced the message, Value of type String cannot be converted to 1-dimensional array of String.

So, anyone have any idea of what is going on with these?  TIA -

 

0 0
replied on February 2, 2024

Well ... by no means an input parameter, defined as string but can't be retrieved as string but array of string.

I hit this when there is no debugging capability of workflow designer. 

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

Sign in to reply to this post.