Create DOCX document from template - Parsing Unexpected Character

I have been using Forms with Power Automate and Plumsail Create DOCX document from template for nearly 2 years. I have a form automation that has been working successfully until recently that is failing on the Plumsail Create DOCX document from template.


Error message:

"error": {
"code": "ApplicationResultException",
"message": "After parsing a value an unexpected character was encountered: O. Path 'RecMethod', line 1, position 625.",
"date": "2021-01-27T01:43:45.4377823Z"


The data that is being processed for this field is ["On-line"]. The Microsoft Form has Multiple Selections allowed for the relevant question and passes the data in the brackets with quotes. This has been working for a long time, but all of a sudden the Create DOCX is failing when it receives data in this format.

I have also noticed the format of my Create DOCX has changed in about the same period of time. I had it formatted nicely one line after the next. Now it is one like string when I edit the Automation. Not sure if this is related.

I am having to stop sending data from fields that are generated from Form questions that allow the selection of multiple answers.

Any assistance would be appreciated.

Jeff

Bit more info. This was the section from Template Data that failed.

"RecMethod":"["On-line"]",

Hello @Jeff_Griffith ,

There seems to be an issue with these brackets. I'm discussing the issue with our developers and will keep you posted about the results.

Best regards,
Petr Bushuev
Plumsail team

Hello Petr,

Actually, I think it is the " that is the issue. I counted to Position 12 Line 12 in another flow that failed and it is the " in that position.

In the error message I posted in the first post, you can see it is referring to the " on Line 1 position 625. Because Create DOCX uses " (quotes) around the fields, I am wondering if it seeing the quotes " as an instruction rather than data.

Hopefully that made sense.

'RecMethod', line 1, position 625."

Hello @Jeff_Griffith,

Yes, it's this symbol and actually, it makes the JSON incorrect. Could you try to parse the dynamic values and probably replace the " symbols with a single quote ' ?

Best regards,
Petr Bushuev
Plumsail team

The issue only recently appeared. The automation has been working for nearly 2 years without an issue. The " is being sent by Microsoft Forms when you have a question that supports multiple answers. I do not know how to stop Microsoft Forms from sending the " around the response when there are multiple answers.

Hello @Jeff_Griffith ,

It seems to be related to some update of the Microsoft Forms. The resulting JSON becomes incorrect, even if we check it with some third-party validator. For example, this one

We're discussing a possible solution that could be provided from the Plumsail side. I'll keep you posted about the results.

Best Regards,
Petr Bushuev
Plumsail team

Hello @Jeff_Griffith,

We researched the issue. It seems that currently, Microsoft forms return an array from Choices when previously it was a string. It caused the issue with the double quotes. As a possible workaround, you can remove the quotes from the JSON in plumsail action.

Best regards,
Petr Bushuev
Plumsail team

Thank you Petr. I will test that out.

I tested and it is finishing without failing, but writing incorrect data.

The template data in Create DOCX shows "BodLoc": ["Hand","Arm"],

The PDF that is created shows: System.Object[]

So ["Hand","Arm"] was replaced with System.Object[]

Hello @Jeff_Griffit,

It's possible to get a correct answer using the standard MS Power Automate function Replace.

I used this solution

This is my flow example

I used this replace function

replace(replace(replace(replace(variables('Choice'),'[',''),']',''),',',';'),'"','')

Best Regards,
Petr Bushuev
Plumsail team

Hello @Jeff_Griffith,

I'd like to post another solution for DOCX templates. To insert an array from Microsoft Forms you can use a template's formatter Join. So, add the formatter to the docx template instead of your previous tag:

{{your_tag}:join(; )}

and then just use MS Forms dynamic content. There won't be this "System.object[]" output but your data from the form.

Anyway, you need to remove the double quotes from the dynamic content in the action.

Best regards,
Petr Bushuev
Plumsail team

Thank you for your assistance with this Petr. I have been able to resolve the issue by removing the quotes for form entries where multiple selections are required.

However, employees often enter a " character in comments fields. This also breaks the Create DOCX document from template.

I am just curious about what options might exist for Plumsail not to break when a quote is in the text. As noted when I started this post earlier this year, I have been using Plumsail for nearly 2 years, but the problem only appeared over the past 6 months.

I can see that Microsoft was using the brackets [ and quotes " to at least mid last year, looking at some of my list entries.

I have a PDF report created by Plumsail in October last year that has a " used in the text of a form response. It was definitely working prior to January of this year.

Any chance this could be looked at internally and see if there is someway to revert to where Create DOCX does not crash on the quote " character?