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

Question

Question

SetTokenValue() method sets the value as a string, need to set explicitly as a number

asked on October 28, 2020 Show version history

I have a very simple script in my workflow to grab the size of all documents in a folder to make sure that an email activity won't fail later:

        protected override void Execute()
        {
            // Write your code here. The BoundEntryInfo property will access the entry, RASession will get the Repository Access session
            FolderStatistics attachmentsFolder = Folder.GetStatistics((int)GetTokenValue("FindEmailDeliveryFolder_OutputEntry_ID"), RASession);
            long attachmentsFileSize = attachmentsFolder.TotalFileSize;
            
            SetTokenValue("Attachment File Size", attachmentsFileSize);
        }

But the problem is, it is assigning my attachmentsFileSize as a string to that token, which is making it difficult to evaluate because the comparison is alphabetical, not numeric. So files that are actually only 400,000 B are evaluating as more than 25,000,000 B, because 4 is greater than 2 alphabetically.

Is there a way to force that token to represent an integer, or a number? I expected that passing it a numeric data type would make it store the numeric value, but I guess not.

0 0

Answer

SELECTED ANSWER
replied on October 28, 2020

there is another way of work around. Use "TokenCalculator" activity in Workflow and convert the token string to an integer.

 

 

1 0

Replies

replied on October 28, 2020

I think in workflow you can define token type

 

 

make it integer only so you won't get string.

1 0
replied on October 28, 2020

Thanks, I just added that as an activity outside of the SDK script. I was using the SetTokenValue() method to create a token within the script, which is usually more maintainable - is there a way to set the token type within the script? That method returns void and I don't see any documentation on creating tokens in WF SDK (I don't even see any documentation on the SetTokenValue method) so I can't think of a standard way to do it.

0 0
replied on October 28, 2020

Unfortunately that approach didn't work. In this instance I have set it to a long integer to match the datatype returned from the TotalFileSize property:

And it still converts it to a string:

0 0
SELECTED ANSWER
replied on October 28, 2020

there is another way of work around. Use "TokenCalculator" activity in Workflow and convert the token string to an integer.

 

 

1 0
replied on October 28, 2020 Show version history

The script activity changes its type to string. Add a Assign Token Values after the script and create a new token with the desired type, then assign it the value from the script (basically, the same thing Luke suggested with Token Calculator).

Or create a "maxSize" long int token and set its value to 25000000. Use that in the left hand side to compare it to the token resulting from the script. The type of the left hand side of the condition determines the expected types for values.

1 0
replied on October 28, 2020

Thanks Miruna - is there documentation on that method? I checked in all four of the chm files that install with the SDK and didn't see any mention of it.

0 0
replied on October 28, 2020

Sorry, I should've been clearer. There is no way to create a token of any other type than string from script activities.

You can use Assign Token Values to create the "maxSize" token and tag is as long integer.

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

Sign in to reply to this post.