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

Question

Question

Workflow Output Parameters - Confused about Use Assign Token Values activity to set the values of output parameters checkbox

asked on January 23, 2014

This check box is causing me some confusion. I had no plans to use the Assign Token Values activity to set the value of my output parameters. I wanted to use the script activity.

 

I left this unchecked and set the output token as I would any other token but the token was returning blank. The only way I could get data into my output parameters was the following:

 

Go back and check the Use the assign Token Values activity to set the values of the output parameters

Create a placeholder token at the start of the workflow

Update the placeholder token in the workflow

Use Assign Token Values activity to assign the value in the placeholder to the output parameters

 

This seems like unnecessary steps, am I doing something wrong?

0 0

Replies

replied on January 23, 2014

Hi Chad,

 

We provided two different ways to set the value of Output Parameters for your workflow because different people found it intuitive in different ways.

 

Option 1: Use Assign Token Values

The "Use the Assign Token Values activity to set the values of output parameters" checkbox is checked.  The workflow will create blank tokens for each of your Output Parameters.  It's up to you to add Assign Token Values activities to your workflow, select the Output Parameter token you want to modify, and set its value in that activity.

Advantage: You can set the value conditionally and update it at multiple points in your workflow (say, in two different branches).

Disadvantage: You have Assign Token Value activities cluttering your workflow and you have to manually add them.

 

Option 2: Set the Output Parameter values in the Input/Output Parameters dialog

When the "Use the Assign Token Values activity to set the values of output parameters" is cleared, an additional column is shown in the Output Parameters section of the dialog.  This Output Value column can be used to set the value of each Output Parameter.  Any token created in your workflow is available for use as a value (effectively, this process is happening at the very end of your workflow).

Advantage: Your workflow is cleaner and all output parameter values are configured in the same place.

Disadvantage: Each output parameter is constrained to have a specific value and can't easily be updated based on how your workflow has run.

 

You mentioned that you want to set the Output Parameters using a Script activity.  Either of the above options will work, but in both cases you'll want your Script activity to create tokens with the values that your script retrieved/generated/whatever.  You'll then use the Script activity's tokens in one of two places:

Option 1: The "New value" section of a modified token item in an Assign Token Value activity.  This sounds like what you're doing already.

Option 2: The "Output Value" column in the Input/Output Parameters dialog.

 

If no tokens are listed for your Script activity in the token menu, see Mike Wu's response to make sure you are creating them correctly.  I also recommend using the Run Workflow feature to test your workflow as it creates two tabs that'll be helpful to you: Tokens and Parameters.

1 0
replied on January 23, 2014

Ok. I am using Option 2 now, after adding the two additional activities for the placeholder and the updater. I originally was not using either Option 1 or Option 2.

 

I was using the Output Parameters that are available directly in the script editor Token Browser. So the line of code would look something like this

 

this.SetTokenValue("AD Email", str) ;

 

Where "AD Email" is the name of my output parameter.

 

This appeared to be the most efficient way, there was no need for additional tokens or activities. It just doesn't work, the AD Email gets reset to blank before it is returned to the invoking workflow.

0 0
replied on January 23, 2014

For option 2, please make sure you've marked the token as global (in the Script Tokens pane in the Script Editor). Otherwise, you need to use this.SetActivityTokenValue in order to create the token first (and it will be prefixed with the activity name).

 

We'll look at the string/behavior and see if we can make it more clear.

 

You don't need Assign Tokens to create the token before you set it in order to use option 1. Yes, the Designer will warn you that your parameter may not be set right when you try to publish the workflow, but it will allow you to publish. And if your script creates the token with the right name, everything will be fine.

 

 

0 0
replied on January 23, 2014

If you're talking about assigning a token value with a custom Script activity, I would propose the following: 

 

1. Create a placeholder token before the Script activity using the Assign Token Values activity.

2. In the Script Editor, map the correct value to the token with SetTokenValue("Token_Name", Token_Value). 

3. Still in the Script Editor, click on the Script Tokens tab at the bottom of the editor and then click Auto Detect Tokens button. The token you assigned in the script should appear. Be sure to set the scope of the token and whether it's multi-valued or not with the checkboxes to the right.

 

That's it, you don't have to use the Assign Token Values activity following the Script activity, the token value has already been mapped and it's ready for use.

0 0
replied on January 23, 2014

The problem is the token I am assigning is an Output Entry token. When I assign it directly with a script the Workflow outputs a blank value. If I assign it with Assign Token Values it works.

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

Sign in to reply to this post.