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

Question

Question

Need help with a workflow -- Calculate extended price in multi-value field

asked on December 9, 2019

I am attempting to set a field in a Multi-Value field.  Specifically I have a multi-value group for line items (description, quantity, price/per, total price) that I want to calculate the total price (quantity * price/per) for each line item.  The workflow is fired with a condition rule when a field set changes.

 

In the following workflow the token track shows the calculation results correctly but when Assign Field Values task is executed the last calculation is stored in the first item of the group and the rest of the items in the group are blank.

 

1 0

Answer

SELECTED ANSWER
replied on December 10, 2019 Show version history

Okay, so the first thing I notice is that your Assign Field Values is set to Append the Item Prices, which means it will not update any of the existing "rows" it will just add more at the end.

Your Assign Field values needs to overwrite the "Total Price" fields entirely to ensure it doesn't leave those blank ones behind and create that offset.

 

Second, you have an extra step in the Assign Token Values 2 activity where you're just overwriting the current values before you add anything.

As a result, you end up with two of the same value.

You can see this in the Token results because the Item Prices go 11,11 -> 40,40 -> 9,9 instead of 11 -> 11,40 -> 11,40,9

The highlighted piece below is overwriting the existing values before the second part appends the new value so you lose your previous value(s).

It should only have the Append part. You added the highlight part too and that sets Item Prices equal to the token value, which is breaking everything.

0 0

Replies

replied on December 9, 2019 Show version history

You need to use a multivalued Token when you assign the value to the field.

The way your workflow is currently configured, it is just recreating/overwriting the Token Calculator result in each iteration of the loop, which is why you only end up with the last value.

Add a token to the start of your process called "Item Prices" or something like that, then set it to be a multivalue token so it can hold multiple values.

Inside of the loop, after the Token Calculator, assign the token calculator result to your "Item Prices" token and select "append value" so it will add the value for that iteration to the list.

Then, when you set the field values use the "Item Prices" token.

It is important that you create the token before the loop and only update the values inside the loop. If you try to create the token inside of the loop you'll have the same issue as with the token calculator, namely that it will just overwrite/recreate it each iteration.

1 0
replied on December 9, 2019

Thanks for your reply but I am not getting it.  I changed the workflow below.  When this Workflow executes the original line items are not calculated but there are 3 more line items added to the document with the correct calculations.

 

0 0
replied on December 9, 2019

You cannot put the assign field values in the loop, you should leave that where it was. You should never update field values inside of a loop like that.

You did not add the multi-value token I mentioned, and that is what you absolutely need to make this work.

What you need to do is:

  1. Create a new token in your "Assign Token Values" activity.
    • Call it "Item Prices" and check the box to make it multi-value
  2. Add an additional "Assign Token Values" activity inside the loop immediately after your Token Calculator
    • Choose Modify and select your "Item Prices" token
    • Set the value as the Token Calculator result and choose "append"
  3. Leave your Assign Field Values outside of the loop
    • When setting the "PS Item Total Price" field, use the new "Item Prices" multi-value token, not the token calculator result.

 

0 0
replied on December 9, 2019

I appreciate the help but it is still not working.  Changed the workflow as follows

 

0 0
replied on December 9, 2019 Show version history

Why did you change your "for each value" to iterate through the new Item Prices token? That new token doesn't have any values to iterate through at that point.

You need to iterate through something that actually has values like the Quantity or Unit Price field "all" token as you had it in your original example.

Leave everything else exactly how it is in your latest screenshot, but change the For Each Value to how it was originally (using RetrieveFieldValues_PS Quanity_All)

0 0
replied on December 9, 2019

I did have the iterator specified as RetrieveFieldValue_PS Quantity_All but it failed.  I changed the iterator and it also failed (which it should -- that is the screenshot I took -- sorry).  I changed it back and it still fails.

 

I am using WorkFlow Designer 10.2, WF Server 10.2, LF Server 10.2

0 0
replied on December 9, 2019

Failed in what way? I need more specifics about what is going wrong in order to determine what needs to be fixed. A lot changes were made between each of your screenshots so it is kind of a moving target.

Can you send a screenshot of the configuration exactly how it was in your most recent screenshot, except change only the iterator on the For Each Value.

Then, when you run the workflow, get a screenshot of the token tab to see what values are actually being generated/stored.

0 0
replied on December 9, 2019

I have attached a spreadsheet of the token results.  I have removed any server references for security reasons.

 

Workflow:

token_diag.xlsx (11.46 KB)
0 0
replied on December 9, 2019

It failed by not calculating the extended price and in this configuration it added 2 blank group items with the extended price calculation of the last one (3 * 3.00).  So three original with no calculation and 2 new ones added by the workflow with the last (of the original) calculation.

0 0
replied on December 9, 2019

I appreciate the help but it is still not working.  Changed the workflow as follows

0 0
replied on December 10, 2019

I have attached a spreadsheet of the token results.  I have removed any server references for security reasons.

It failed by not calculating the extended price and in this configuration it added 2 blank group items with the extended price calculation of the last one (3 * 3.00).  So three original with no calculation and 2 new ones added by the workflow with the last (of the original) calculation.

Workflow:

token_diag.xlsx (11.46 KB)
0 0
SELECTED ANSWER
replied on December 10, 2019 Show version history

Okay, so the first thing I notice is that your Assign Field Values is set to Append the Item Prices, which means it will not update any of the existing "rows" it will just add more at the end.

Your Assign Field values needs to overwrite the "Total Price" fields entirely to ensure it doesn't leave those blank ones behind and create that offset.

 

Second, you have an extra step in the Assign Token Values 2 activity where you're just overwriting the current values before you add anything.

As a result, you end up with two of the same value.

You can see this in the Token results because the Item Prices go 11,11 -> 40,40 -> 9,9 instead of 11 -> 11,40 -> 11,40,9

The highlighted piece below is overwriting the existing values before the second part appends the new value so you lose your previous value(s).

It should only have the Append part. You added the highlight part too and that sets Item Prices equal to the token value, which is breaking everything.

0 0
replied on December 10, 2019

That is it!  Thank you.  I did not even notice the modify in the Assign Field value activity and the append now makes more sense to me.  Does append act this way with all field values?  Or only Multi-Value fields?  I assumed append meant to append the values to the existing field value, not append another field to the metadata.

0 0
replied on December 10, 2019

Append is only an option for multi-value fields, and Append will never overwrite existing items even if they are empty.

With single value fields, your only option is to replace the value so this wouldn't come up.

0 0
replied on December 10, 2019

Thanks Jason.  Appreciate the help.

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

Sign in to reply to this post.