cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ChrisCollao
Helper I
Helper I

Populate optional images on a Word template from a Form

Hi everyone,

 

I would like to ask if theres a way to build a Flow that allows to put an image in a Word template pulled from an optional (it must be optional) question from Forms.

 

Basically... I have a Form where users can answer some questions, and load an image (optional).

This answers are being loaded to a Word template.

This word template has a field where the image can be loaded. But the image must be optional.

 

Any ideas?

 

Thanks a lot.

 

If you need pictures, schemas or more info, just let me know.

1 ACCEPTED SOLUTION

Accepted Solutions
v-litu-msft
Community Support
Community Support

Hi @ChrisCollao,

 

At first, we should use empty() function to determine the answer of Optional image whether is empty, if there is no image upload, the answer will return null, empty() function will return true. If it not return true, get the uploaded file content and populate it into the Word template:

Annotation 2020-07-06 144758.jpg

About get the upload file content in the MS Form, please refer to this post:

https://powerusers.microsoft.com/t5/Building-Flows/Working-with-files-from-the-Forms-quot-File-Uploa...

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-litu-msft
Community Support
Community Support

Hi @ChrisCollao,

 

At first, we should use empty() function to determine the answer of Optional image whether is empty, if there is no image upload, the answer will return null, empty() function will return true. If it not return true, get the uploaded file content and populate it into the Word template:

Annotation 2020-07-06 144758.jpg

About get the upload file content in the MS Form, please refer to this post:

https://powerusers.microsoft.com/t5/Building-Flows/Working-with-files-from-the-Forms-quot-File-Uploa...

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hi @v-litu-msft  , thanks for your help.

 

With your way I should create 2 word templates? One when there's an imagen, and another for when there is not?

Hi @ChrisCollao,

 

Yes, if the image exists, go to the branch to append the image into Word template, if not, go to the brach not append image.

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-litu-msft thanks again... 

 

Hmmm... Okay, not a very elegant way to solve it. Because if I need 3 optional images, then I should create 9 different word templates to satisfy all the possible branches. Right?

 

Will try this option and let you know.

 

Best regards.

Digital
Responsive Resident
Responsive Resident

Did you solve this by using multiple word templates with and without images? I'm have the same problem and this just seems absurd that you can't pass a blank value so that field is ignored in the template.

Hi @Digital , sorry for the late.

 

Yes, I couldn't find another way, there's not much material online about this kind of use for that function.

 

Here you can see the tree with just 2 images:

populatetree.PNG

 

Basically on each condition I do check if the output of the question where should be an image is empty, one for each output. When is not empty, I use compose to obtain the name of the file and then I use the "get file using path" onedrive connector. After you populate the template you must create the file, so to "merge" all the outputs I did this:

ChrisCollao_0-1620397862924.png

 

In the *Field Content I used an "if" where I check on every Populate template output if it's empty, if empty it checks the next one and so on.

 

ChrisCollao_1-1620398015718.png

 

It's not fancy but it works. If you have 3 optional images then you must create a tree with 9 templates.

 

The 0s and 1s makes reference to if there's image or not. Just a way of name I managed to not go crazy. 0.0 means the file where are no image fields, 1.1 is where are two images.

 

Finally... Some notes apart that you should know:

- The populate word template step crush if the file size it's greater than 10 MB. It kind of sucks because in Forms the smaller maximum file size you can set it's 10MB. So... if a user uploads 2 or 3 pictures bigger than 4-5 MB, your flow will crush in that step. There's some services that can resize the files, but they are external.

- You should use error management in the create file and convert file steps. Sometimes they crush because they "can't reach the file" or the URL is not correct. It's a onedrive lapsus and you can solve them if you set some retry mechanism. I did a "do until" where the flow retries every 5 minutes up to 1200 times until a variable is changed after the succesful step.

 

ChrisCollao_2-1620398729317.png

 

Let me know if you could make it or if you have any other question 🙂

 

Best regards.

 

Helpful resources

Announcements
MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (30,508)