Hi Team,
I'm reaching out because I've encountered an issue after upgrading the OfficeUtils modules to version 5.8.0. Specifically, I'm seeing the following error message: "target" and the error stack details are as follows:
at NPOI.OpenXml4Net.OPC.PackagePart.AddExternalRelationship(String target, String relationshipType, String id)
at NPOI.XWPF.UserModel.XWPFParagraph.InsertNewHyperlinkRun(Int32 pos, String uri)
at OutSystems.NssOfficeUtilsExternalLib.Word.ReplaceTextWithText(XWPFParagraph p, String pattern, Int32 matchIndex, STWordTextStructure wordText)
at OutSystems.NssOfficeUtilsExternalLib.Word.ProcessParagraph(XWPFParagraph paragraph, RCWordFileRecord ssWordFile, List`1 ParagraphsToRemove)
at OutSystems.NssOfficeUtilsExternalLib.Word.ProcessParagraphs(IEnumerator paragraphsEnumerator, RCWordFileRecord ssWordFile, List`1 ParagraphsToRemove)
at OutSystems.NssOfficeUtilsExternalLib.Word.GenerateWordFile(RCWordFileRecord ssWordFile)
at OutSystems.NssOfficeUtilsExternalLib.CssOfficeUtilsExternalLib.MssGenerateWordFile(RCWordFileRecord ssWordFile, Byte[]& ssWordBinary)
The only function I'm calling is Word_Export_SetText. The issue appears to be related to multiple placeholders, and the first one I've identified is:
{
"WordOutput": {
"OutputType": 1,
"Placeholder": "{Contact.Address_2}",
"DeletePlaceholder": true
}
There doesn't seem to be anything unique about this placeholder—it's not the first one with an underscore, nor the first one with DeletePlaceholder set to true. The corresponding text in the Word document is also quite ordinary.
I'm wondering if anyone else has encountered similar issues, or if you have any suggestions on what might be causing this problem. Any feedback or guidance would be greatly appreciated.
Thanks in advance for your help!
Hi Ibbe,
The stack trace gives us a clear starting point. The error originates in NPOI's AddExternalRelationship(String target, ...), where the target parameter (a URI) is either null or empty. The call chain shows that ReplaceTextWithText is invoking InsertNewHyperlinkRun, which then fails when trying to register that URI.
There are two plausible scenarios here, and I'd suggest investigating them in this order:
1. The placeholder or surrounding text contains hyperlink formatting in the template.
In Word, it's common for text to carry hidden hyperlink formatting without any visible indication, especially if it was pasted from another source. When OfficeUtils processes the replacement, it may encounter a hyperlink run and attempt to reconstruct it with an empty or missing URI, which would cause exactly this error. To rule this out, open the template, select the area around {Contact.Address_2}, and check whether Word shows any hyperlink formatting (right-click > "Remove Hyperlink" is a quick way to test). If you want to be thorough, you can rename the .docx to .zip, open word/document.xml, and search for elements near that placeholder.
2. A possible defect in the 5.8.0 deletion path.
I notice your configuration has DeletePlaceholder: true with OutputType: 1. If OfficeUtils 5.8.0 introduced changes to how placeholders are deleted, and the code path for deletion incorrectly enters InsertNewHyperlinkRun with no URI to pass, this would produce the same error regardless of whether there's a hyperlink in the template. Since you mention the issue appeared after upgrading to 5.8.0 and the template itself hasn't changed, this is worth considering. Testing with DeletePlaceholder: false (and an empty replacement text as a workaround) could help isolate whether the deletion logic is the trigger.
As a temporary workaround, reverting to the previous OfficeUtils version should bypass this, though keep in mind there may have been reasons for the 5.8.0 update (security patches, other fixes) that are worth weighing before staying on an older version long-term.
Either way, I'd recommend reporting this on the OfficeUtils Forge component page under the Support tab with the stack trace and your placeholder configuration. If this is a regression, the component author would need this information to address it.
Hope this helps narrow it down.
Hi @Ibbe Verlooy ,
Can you try to revert to the previous OfficeUtils version (5.7.0)? Not sure if this was the version you were using before.
I have upgraded the extension target to .NET Framework 4.8 on the last release (5.8.0), and it might be the case that the corresponding runtime is not present in your OutSystems platform installation.
Best,
Bruno
Hi Bruno and Afonso,
It turns out that setting DeletePlaceholder to true was causing the problem. I have now changed it to false and provided an empty text value instead ( As suggested by Aflfonso). Everything appears to be working smoothly now.
Thank you both for your prompt responses and help. I really appreciate your willingness to jump in and assist so quickly.
Best regards,
Ibbe