Template Date and Variable

Hi,

I try to populate a docx from a template like this using power automate:

image

The problem is when I run the flow the data in Template data is like this:

{
"FirstName": "John",
"LastName": "Doe",
"items": [
" // This quotation mark
{"Relative_FirstName":"Bob","Relative_LastName":"Doe"},{"Relative_FirstName":"Jane","Relative_LastName":"Doe"}

" // This quotation mark
]
}

why are the escape characters added and the quotation marks? They are not in the variable Relatives.

Hello! As I understand, the type of the variable is string though I am not sure why you have there the double slashes. Please share the full configuration of your flow (all actions should be opened) and the raw output of the action(s) which define the value of the variable?

Hi Evgeniy,

Yes the the variable is string. I go through the records of a database and use append to populate the string.

image

the output for the Create Docx from template is like this:

But if i copy the Data Template content and put it somewhere else, for example send email notification it is like this.

It is just different presentation of the same string. In the case of our action, you see the back slashes as escape characters. It means that they mark the double quotes that are part of the string and should not be considered as its beginning or ending. Thus, in our action the "items" property contains an array with one item and this item is the string you shared. The slashes will not be put in the result document. But I do not see sense in putting the variable into the array. If you need one, you could initialize an array variable from the very beginning and append the data to the array variable as separate items.

1 Like

That worked, thanks.

1 Like