Marple revealing jewel

The Secret of SetWordTemplate

My last blog was almost over a year ago and promised a break down of my talk at the now, sadly, disbanded SPPUG event…. That breakdown is still to come (although I have submitted it to a few conferences so it might have to wait until after that if I somehow get accepted).

It’s been a busy year of contracting and juggling family commitments, and a fair few holidays! I haven’t avoided the blog, in fact I must view it at least once a month, to view my Expand query article, mostly. Which is why I’m dusting off this blog to capture something I struggled with this week – so that I can find it again, should the need ever arise.

I’m currently working on a big dynamic Document Generation piece, using a Document Generation Rule configuration table which dictates in a specific scenario which templates to create and save to the record sharepoint library. As this is so dynamic, then using an Unbound action on the custom table is the only way. So I needed to create my own Workflow Action first off

Creating a Custom Workflow Action

So the first step is to create a new classic Workflow Action through Automation -> Process -> Action

It’s going to be an unbound one, so the Add to option should be set to None

So we need to add two Input Arguments, for the out the box documenttemplate table and one for our custom table (using the TV Show one for this example)

The add a Perform Action step and pick SetWordTemplate from the list

Then we have to go to Set Properties which is where I hit problems!

The Problem

It was fine for the SelectedTemplate with the Document Template table, which is out the box. I could easily select the record guid to use. However when I attempted to set the Target to my TV Show record, the guid for that record wasn’t available. I could just select system record lookups.

How to resolve

After a day of trying to work out how to get my custom table to work, I finally stumbled across the strange solution.

I realised that I likely needed to Enable attachments as SetWordTemplate works by taking the reference to a system document template, a specified record, merging them and then saving in a Note (annotation) associated with the specified record.

So I enabled this and publish, refreshed, waited a while, then waited a bit longer but the situation was still the same. I couldn’t select a TV Show record as the Target.

What was the answer? Good old classic solution editor.

Once I had opened the settings through the Classic experience for the TV Show table, I needed to switch on Business process flows for the table. No idea why, but that fixed it!

Once I’d made that change, and saved and published I returned to the Action editor, and my record guid was now available to select and set up correctly.

Using it in my Power Automate flow was another rollercoaster – so that might be next weeks topic. But for now, I’m taking advantage of all the Agatha Christie shows on Netflix and enjoying the rest of my Sunday evening.


Posted by

in

,

Posted: