Mail merge Regions with HYPERLINK field

taxinvoice-template.docx (63.2 KB)
test-data.zip (879 Bytes)

Test:
6526fa4fa1970.pdf (103.3 KB)
6526fe7c1f979.pdf (124.2 KB)

We are using Aspose Cloud Words to mail merge an invoice. In the invoice we want to mail merge a HYPERLINK field using thirdparty_payment_url. We must use regions to repeat table rows.

It appears as though HYPERLINK with regions enabled does not support a MERGEFIELD value and the field does not merge correctly. The hyperlink works with regions disabled.

It is possible to run 2 mail merge requests on the file with regions disabled then enabled but this is slow.

Please advise.

Tim

@digeratisolutions

Please note in the scenario that you have two types of data: normal data and list(region) data. You have two solutions. If you want to keep the existing template and data file, then you need to call the MailMege API twice: once withregions parameter set to false and later updating the output file using withregions parameter set to true.

The second solution is to enclose your data in a parent list(region), update your template accordingly, and call the MailMerge API once with the true value of the withregions parameter.

Hi Tilal,

In the template provided we have two examples of the HYPERLINK field. One instance is above TableStart and one is within.

image.png (3.9 KB)

When withregions is true, neither field works.

image.png (3.2 KB)

@digeratisolutions

It seems there were two issues. First, your data has duplicate field names, and the HYPERLINK field in the region has a formatting issue in the template file. I have updated your template and data file, and now the HYPERLINK field is working fine with both true and false values of the ‘withregions’ parameter.

taxinvoice-template.zip (163.7 KB)

We require further assistance please.

I have compared our XML with the one said to have errors (with a tool) and the only difference I can see is a space at the end of your hyperlink value. Are there further errors?

test-local.zip (949 Bytes)

We have uploaded the supplied template you provided and got this result.

652f1324a2f26.docx (57.4 KB)

Are we missing anything in our request?’

Root=1-652f1325-22bdf84d5ef479fe499fa52f

@digeratisolutions

As per my understanding, there was a duplicate field (thirdparty_payment_url) in your XML data. However, the test-local.xml file seems fine. I used it to merge with my above shared updated template and it seems okay to me. Please check and confirm. If you still face any issues, then please share your expected document along with the sample code. You can create your expected document using MS Word.
test-local_output.Docx (57.8 KB)

We’re using aspose-cloud/aspose-words-cloud@22.1 PHP SDK, our code is:

            $request = new Requests\ExecuteMailMergeRequest(
                $template->get_template_filename(), // name
                $data, // mail merge data
                null, // options
                null, // folder
                null, // storage
                null, // encoding
                null, // password
                null, // encrypted_password
                true, // regions
                null, // mail merge data file
               'ContainingFields,EmptyParagraphs,UnusedFields,UnusedRegions', // clean up
                null, // use whole paragraph as region
                $result_filename  // resulting file name
            );

Please advise what we’re doing wrong to render an invalid document?

@digeratisolutions

You are using quite an old version of Aspose.Words Cloud SDK for PHP. Please try the latest version; it will resolve the issue.

We have updated to 23.10.0 and it’s still not working :disappointed_relieved:

Test result, same code same merge data. What could we be doing wrong?
6530acf1bce71.docx (57.4 KB)

If I remove all clean up properties 'ContainingFields,EmptyParagraphs,UnusedFields,UnusedRegions' and pass null it works.

Are you able to advise which key is causing the issue and why?

@digeratisolutions

It seems the ContainingFields option is removing the Hyperlink field inside the region. I have logged a ticket (WORDSCLOUD-2511) for further investigation. We will share our findings with you soon.