You are viewing limited content. For full access, please sign in.

Question

Question

Update Word Doc in Workflow without using Business Process

asked on July 19, 2022

For context what I am trying to accomplish is having a preview window where a user can view what a invoice (or any document is being generated) can be previewed before being submitted and continuing the business process. 

The basic preview page (with no polish, bells, or whistles) looks like this:

Since this requires being able to trigger the workflow an unspecified number of times without advancing the business process, I use some JavaScript to grab the variables and then start an instance of the workflow when my preview button is clicked here:

The issue I am having is within the table field merge in my workflow. For reference, this is what my workflow looks like:

The collections are passed as pipe delimited lists (eg. apples|bananas) and then are split into multi-value tokens in the pattern matching. The reason my workflow contains retrieve business process variables is 'Update Word Doc' will not let you assign the table field merge with anything other than variables from a Forms table or collection - so what I do is 'import' these variables as a kind of template and then replace them with the multi value tokens I created in the pattern matching... except this does not work.

My track tokens activity shows that the variables are correctly assigned as multi-value tokens:

but when run, the word document retains the <<variable names>> and does not update (I tested the word template with a test workflow and it works when run from a process). Here is what the table field merge within my update word doc activity looks like:

Does anyone know how I might go about getting Update Word Doc to let me use my non-process multi value tokens? Please let me know if you need any additional information or screenshots.

0 0

Answer

SELECTED ANSWER
replied on July 25, 2022

For anyone attempting to do this in the future:

Use a stored proc to store the collections to a SQL table. By assigning an id in a separate table and storing this in a hidden field, you can organize all the collection items in the table by this id, and more importantly since you are already passing this as a variable to your stored procedure, to trigger the lookup rule you just need to use JavaScript to trigger a change on the field when your preview button is pressed. 

From there your workflow just has to grab the values from the table, and then update a separate table with the entry ID of the new doc, which can be grabbed via a lookup rule.. In your form you'll want to use an async function and some awaiting and delays so all the data and functions have time to run before you try to grab the newly created document.

0 0

Replies

replied on July 20, 2022

Table merges require the use of one of the activities that produce tokens. It does not use multi-value tokens per se, it uses the table columns retrieved from the form. The individual column tokens produced by Retrieve Business Process Variables are not available for update outside of that activity.

One more thing to keep in mind is that Workflow is asynchronous, so your instance is not guaranteed to start immediately as you invoke it from JS. It could get queued on the server.

0 0
replied on July 20, 2022

Thanks for your response!

Inside my 'Table Field Merge', within the 'Update Word Document' activity, when I go to select 'Source Data File' the only option is the 'Retrieve Business Process Variables' activity, and when this activity is deleted, there are no options.

How do I go about getting the 'Update Word Doc' activity to let me use tokens defined within my workflow?

0 0
replied on July 21, 2022

That is the expected behavior. Table merges would only work with results of Retrieve Business Process Variables, Query Data, Find Entries or Search Repository.

You could write your values to a table and query that so you use one of the supported activities to generate the data. But again, this workflow is not likely to produce the expected user experience because it may not run immediately to produce a visible result to the user in the expected timeframe. And adding more moving parts may add more time to the overall run time.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.