Solved

How to merge files in NWC workflow from Form attachments?


Badge +9

The users are filling an Input start Form on NWC with attachments. 

we want to generate a PDF into document template from the filled form and append the attachments provided on the form to the generated PDF as one document before sending it to the users to approve. 

We are able to use docgen to generate the pdf from the form data. But can someone help and explain how can we merge the attachment files? detailed steps will be appreciated..  new to NWC. 

 

Thank you!

icon

Best answer by leighburke 16 April 2020, 00:37

View original

14 replies

Userlevel 5
Badge +13

@cmikhaiel_eDo you know how many attachments there will be?

Badge +9
No, but they shouldn't be too many attachments, probably 2-5 attachments.
Userlevel 5
Badge +13

@cmikhaiel_e So you will need to count the number of files, then conditionally extract the files from the collection by checking against the number of files(See Below). You will then need use the same condition to include the file in your document generation. Here is an export key for a quick sample(RKJsQWzLjz8fp5DWWSCXARPDBeqPcw4dGTmKtzyyPvfTnbtbt), you would add a condition up to the maximum number of files.



 

Badge +4
@leighburke, can you elaborate more on how to merge the attachments to the form created. I am using a loop action to gather all my attachments, but I don't follow how to attach that to the document template I created for my form.
Userlevel 5
Badge +13

@kbarton Here is the workflow again, so you can see my example I made(RKJsQWzLjz8fp5DWWSCXARPDBeqPcw4dGTmKtzyyPvfTnbtbt). You get each file out of the collection and put it in it's own variable. Those are then conditionally merged if they exist in the Document Generation action. 

Badge +4
Thanks @leighburke. I didn't see that option when I was playing around before. So basically you count the collection to see how many attachments you have. Would have to assume a set number in order to populate the template though right?
Userlevel 5
Badge +13

@kbarton you need to know the maximum number of files, you can also make the file being merged conditional on the collection count.

Badge +4
@leighburke, works perfectly. Thanks for explaining and the example.

@leighburke can you please send your workflow key, I am unable to open the workflow using the key in the tread. 

I am trying to merge several pdfs users will be attaching in the form as one document and then place a signature in that attached document package. 


 


Thanks in advance for your help!

Userlevel 3
Badge +9

@leighburke I am interested in this solution. But what do these shared export keys mean? (khEHTFjQaiyYCHdNs7MoYNPSMMFZK7fdqy13GkzUp1SV2gkLr)  How does this bring me to the sample workflow?

Userlevel 5
Badge +13

Hi @WouterT,


 


I have changed the export link to the following(RKJsQWzLjz8fp5DWWSCXARPDBeqPcw4dGTmKtzyyPvfTnbtbt), we have a nice video explaining how to import and export workflows(https://www.youtube.com/watch?v=fC2SDnQHEvE).


 


 

Userlevel 3
Badge +9

Thanks @leighburke for your quick reply! I am going to study this for sure. Wasn't aware of this feature. I asked this actually in the context of this SharePoint Online List Attachment problem I just posted here

Badge +1

Hi @leighburke ,


 


I have created the WF as per your imported version. I have allowed for up to 10 files but when I tested the WF the instance failed with the message being " ! Index was outside the bounds of the collection". Looks like it failed at attempting to check for attachment number 9 and the form only had 8 attachments? The run if actions were configured like yours with the index being greater than a certain number?


 

Userlevel 5
Badge +13

@EleanorK That error looks like the 'run if' ran when it shouldn't I would check the condition and confirm the collection size using a log in details. Keeping in mind the last index value will be 1 less than the count because collections start at 0.

Reply