cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to concatenate string/variables?

Jump to solution

Hi,

I have a pulled out data from a repeating section using xml query.  Inside the loop query xml creates variables for Item, Cost, Qty, Total.  Obviously in the second iteration of the loop, the variables are overwriting with new values..  So I created a dictionary variable outside the loop, then inside the loop again I stored the variables into the dictionary variable. This still doesn't work, I still only get the last items from the loop stored in the variable.

1.  How can I 'concatenate' this data to a single variable, and more importantly, how can I format it also so that I can use it in an email?

Please note: I am using workflow for office365 with workgroup licence, so please be aware that not all the actions/features that are available on-prem are available to me in O365, so please try answer accordingly.

Labels: (2)
Tags (1)
0 Kudos
Reply
17 Replies
Not applicable

Re: How to concatenate string/variables?

Jump to solution

11 Views with 0 replies, does this mean its impossible?

0 Kudos
Reply
Workflow Hero

Re: How to concatenate string/variables?

Jump to solution

Challenge accepted!

Sounds like a common use of form data and a repeating section. You should be using a dictionary per value you are retrieving. So if the repeating section has 4 values (Item, Cost, Qty, Total) as values, then you need 4 dictionaries. In the loop, add an output in the Query XML action for each vale and store the result in 4 single line of text variables. Then the next action should be doing something with those values before you loop and check the next row. If you require them to be stored in a dictionary, then add the Cost variable's value into the Cost dictionary, Qty variable in to Qty dictionary and so forth. If you do this correctly then you will have 4 full dictionaries.

Things to note:

  1. Loop correctly. You need to know how many times to loop, that means you need the count of the items in a variable and an index to compare to. Then in each query xml you retrieve based on the index and stop when index is equal to the count of items. increment the index before the loop ends.
  2. Add to the dictionaries, and you must have 4 as dictionaries are not double level arrays.
  3. As far as I understand it, variables are not scoped to actions but to the whole workflow. So creating a variable for any action makes it available to be used at any time in the workflow.

If you need to print out the entire row (Item, Cost, Qty, Total) info an email, then build a string. You can do this in two ways.

  1. loop through the dictionaries again and build a string
  2. or better, in the original loop AFTER the query xml action getting the 4 outputs and put into 4 variables use a build string action or set a variable action to "concatenate" the values together into a new variable. To prevent this built string from being over written again, save it into another variable using the set variable action for a Single line of text or multi and in the Set properties, set it equal to itself plus the previous built string. ex: a = a + b, so now a == ab
    1. by the end of the loop the final variable will have all information you need to put into an email. Format it along the way as you need.
Reply
Not applicable

Re: How to concatenate string/variables?

Jump to solution

Hi Andrew, a big thank you to you for this information, and for your reply.  This has truly helped me further but has not yet got me over the line.

I don't have a "Build String" action in 365, however technically I don't *think* I need a specific action for that, as I can still join variables together using "Set Variable" for example..

I am still confused though with your first paragraph.  The Query XML action requires me to set an output variable, which I do.  I am not sure where the dictionary variable needs to be set, and why if I already have the value from the Query XML action.  Why do I need to set the same value into another dictionary variable, if I already have it in a text variable from the output of the Query XML?  Or am I misreading you?

Secondly, if I was sending an email INSIDE each loop, it would not be a problem, however I am not doing that.  I need to first get ALL of the rows from the repeating section and have each row 'stored' so that I can use them OUTSIDE of the loop later to assign a using the rows as part of the description and also sending an email with the items from the repeating section included in an email.

Somehow I actually think what you have said above IS actually, still correct, the problem is just a limit in my understanding that I cannot get past yet..

So please help me again 

0 Kudos
Reply
Workflow Hero

Re: How to concatenate string/variables?

Jump to solution

It depends on how you want your data. If you want the Cost variable to have "Cost1 Cost2 Cost3", or have a dictionary variable with Row1 = "Item1 Cost1 Qty1 Total1", Row2 = "Item2 Cost2 Qty2 Total2"

You won't need a dictionary if you use the former in a method i explained earlier. But if you want to save the values as rows in the repeating section, then you need a dictionary.

  1. First use the Query XML action and save the single output of Cost to a variable, Qty to another and so forth.
  2. Then the following action will be adding those values to a single variable so you will have the row by Set a Variable (row) = Item Cost Qty Total
  3. Add the Row to a dictionary
    1. I bet you can combine step 2 & 3

I figured you were only trying to send one email, so the use of a dictionary saving the rows seemed most logical.

0 Kudos
Reply
Not applicable

Re: How to concatenate string/variables?

Jump to solution

Ok so above your talking about 1 dictionary at the end of the loop with 2 rows, but earlier you said 4 separate dictionaries.

Which one is it?

0 Kudos
Reply
Workflow Hero

Re: How to concatenate string/variables?

Jump to solution

It's up to you, either way. You can concatenate the values as described into a single variable per field, or make them per row. If you do not concatenate into a single variable you can use 4 dictionaries instead. If you want them by row, then concatenate into a single variable and then add to a single dictionary. There are probably 3 or 4 ways of coming to the same outcome.

0 Kudos
Reply
Not applicable

Re: How to concatenate string/variables?

Jump to solution

Hi Andrew this is what I have tried now.  I have saved all of my values into separate stings.  Before the end of the loop I use "Set Workflow Variable" to create a new text variable and attempt to concatenate my variables (image).  I believe this is a copy of your a = a + b, so now a == ab example.

I created the variable "AssetString", then have used that as the first value in the value field, and have added my other asset items variables also.

image.PNG

This results in a never ending loop.

Have I still done something wrong here?

0 Kudos
Reply
Workflow Hero

Re: How to concatenate string/variables?

Jump to solution

Where do you retrieve the count of items in the Form XML? You need to use that index to compare to an incrementing number variable during the loop to know when to exit the loop. It looks like I didn't post a url that I commonly review for Parsing Repeating Section, Nintex Forms/Workflow - Parsing Repeating Section Data - Vadim Tabakman

Hopefully it can provide more information into this area as it includes the UDA that finds this count.

0 Kudos
Reply
Not applicable

Re: How to concatenate string/variables?

Jump to solution

Hi Andrew,

I have counted and looped correctly. The problem is with the a=a+b. It seems that with Nintex365 it does not like a variable to be assigned to itself.

Thank you for your time | Andrew Huddleston | Hillsong church | +61297753601

0 Kudos
Reply