Not visible value in nested IF in merge field until manual Update Fields in Word itself

Hi Aspose support
We have one problem with using your great library. In case when IF expressions are using MERGEFIELD also as result part of expression, it does not give expected result. Here is example:

[Case 1: ] Direct euro
{ IF { MERGEFIELD "comp_service_oms_nw"} <> "" €}

[Case 2: ] From expression without quotes around merge field
{ IF { MERGEFIELD "comp_service_oms_nw"} <> "" { MERGEFIELD "comp_service_oms_nw"}}

[Case 3: ] From expression with quotes around merge field
{ IF { MERGEFIELD "comp_service_oms_nw"} <> "" "{ MERGEFIELD "comp_service_oms_nw"}"}

If we run mail merge, and we supply € as result for comp_service_oms_nw variable we get this output:
[Case 1: ] Direct euro

[Case 2: ] From expression without quotes around merge field

[Case 3: ] From expression with quotes around merge field

In case that we select area where field for Case 2 is, right click and execute UpdateFields in word context menu, it would show € for case 2 as expected.

We have a lot of those template in production with syntax from case 2 in use. It is not an option to fix those templates. Before we started to use Aspose.Words, mail merge was done at client browser using activeX, and there it worked (cases as Case 2 would render € without need to any user intervention). Now we are generated Word documents using Aspose.Words on server side, and deliver generated documents to users, but as shown - result is not same as it was.

Is there any ‘workaround’ that would allow us to detect such cases on the fly, and fix it somehow? We discovered that we can execute updateFields in Aspose just before we save word document, that fixes this case, but unfortunately creates different problems (we get Error! Unknown op code for conditional.) in other templates.

If it is possible, we need some help urgent.
Best regards,
Vladimir

Hi, just to add ‘debug’ to previous post, we have dumped Paragraph children for cases 2 and 3, to see what is different. So here are dumps, in form getNodeType(): getText()

[Case 2]:
FIELD_START: 
RUN: IF 
FIELD_START: 
RUN: MERGEFIELD "comp_service_oms_nw" 
FIELD_SEPARATOR: 
RUN: comp_service_oms_nw
FIELD_END: 
RUN: <> "" 
FIELD_START: 
RUN: MERGEFIELD "comp_service_oms_nw" 
FIELD_SEPARATOR: 
RUN: comp_service_oms_nw
FIELD_END: 
RUN: 
FIELD_SEPARATOR: 
RUN: comp_service_oms_nw
FIELD_END: 

[Case 3]:
FIELD_START: 
RUN: IF 
FIELD_START: 
RUN: MERGEFIELD "comp_service_oms_nw" 
FIELD_SEPARATOR: 
RUN: comp_service_oms_nw
FIELD_END: 
RUN: <> "" 
RUN: "
FIELD_START: 
RUN: MERGEFIELD "comp_service_oms_nw" 
FIELD_SEPARATOR: 
RUN: comp_service_oms_nw
FIELD_END: 
RUN: "
RUN: 
FIELD_SEPARATOR: 
RUN: comp_service_oms_nw
FIELD_END: 

So, we can see that Case 3 (that works fine), has additional RUN nodes with double quotes as text. So, we are about to try to ‘hack’ model in a way to detect this cases (which would not be easy) and somehow insert missing RUN: " nodes, but we really dislike this approach of course. Hope that this small analyses would help you in formulating answer for us, and that you have some better proposal how to deal with this.

Regards,
Vladimir

Hi Vladimir,

Thanks for your inquiry. Perhaps you’re using an older version of Aspose.Words; as with Aspose.Words v11.10.0, I was unable to reproduce this issue on my side. I would suggest you please upgrade to the latest version of Aspose.Words i.e. v11.10.0. You can download it from the following link:
https://releases.aspose.com/words/java

I hope, this helps.

Moreover, I have attached a couple of input/output documents here for your reference. I tested the following simple code and it worked perfectly on my side.

Document doc = new
Document(@"C:\Temp\Cases.docx");
doc.MailMerge.Execute(new string[] { "comp_service_oms_nw" }, new object[] { "€" });
doc.Save(@"C:\Temp\out.docx");

Best regards,

Hi Awais,
thanks for feedback. We are using this version:
Specification-Title: Aspose.Words for Java
Specification-Version: 11.7.0.0
Specification-Vendor: Aspose Pty Ltd
Implementation-Title: Aspose.Words for Java
Implementation-Version: 11.7.0.0
Implementation-Vendor: Aspose Pty Ltd
Release-Date: 2012.08.31

I tried your test code and attached docs, it gives same issue as I described. I would try now with latest version that you proposes, V11.10.0.0, and let you know how it goes.

Thanks,
Vladimir

Hi Awais,
we tried new v11.10.0.0 -> and you were right It actually works fine now I saw in release notes:
WORDSNET-6991 UpdateFields calculates QUOTE field value incorrectly

Thank you very much. This issue can be closed then
Vladimir

Hi Vladimir,

Thanks for the additional information. It is perfect that the latest version of Aspose.Words resolves your problem. Please let us know any time you have any further queries.

Best regards,