FieldsHelper - Resulting values of fields

Hi,
I use the FieldsHelper from In previous versions the value of if-fields, included mergefields, commentfields, hyperlinks etc.
With 10.7 these fields are all converted to plain text.
So the problem is:
Hyperlinks won’t work when they are inside if’s or so and these fields are converted to text.
Also other fields don’t work and to do some post-mailmerge custom actions, I inserted fields to post-process, yet they are now converted to text and are gone by the time of post-processing.
As I need to convert if’s first to the result, to check if its empty or not, I cannot change the sequence of the actions.
Best regards,
Kris

Hi Kris,

Thanks for your inquiry.

I’m afraid I’m not fully sure what the issue is. Could you please clarify what behavior has changed which is incorrect?

Also you may want to look into using the updated code from this page here instead:
https://docs.aspose.com/words/net/replace-fields/

Thanks,

Hi,

If I understand correct a field looks like: {code|result} and not {code|result-as-static-text}

An If-Field could look like (in this case there is nothing wrong):

{IF 1 = 2 “equal” “unequal”|unequal}

Yet If we nest fields like this:

{IF {MERGEFIELD field|text} = “” “the field is empty” “the field contains {MERGEFIELD field|text}”|the field contains text}

In this case the result contains the text of the mergefield (in this case text).

And I can understand this, yet a bit wrong as it should be :

{IF {MERGEFIELD field|text} = “” “the field is empty” “the field contains {MERGEFIELD field|text}”|the field contains {MERGEFIELD field|text}} à

This especially is wrong when using this with hyperlinks (don’t know exactly how hyperlinks work, yet you should get the point):

{IF {MERGEFIELD field|text} = “” “” “Click here: {HYPERLINK [www.aspose.com|Aspose](http://www.aspose.com%7Caspose/) }”|Click here: Aspose}

Yet in this case there must be a hyperlink in the result (as does Word):

{IF {MERGEFIELD field|text} = “” “” “Click here: {HYPERLINK [www.aspose.com|Aspose](http://www.aspose.com%7Caspose/) }”|Click here: {HYPERLINK [www.aspose.com|Aspose}](http://www.aspose.com%7Caspose%7D/)}

10.6 did this behavior correct, yet 10.7 and 10.8 has static text as result instead of the “real” result (including fields).

Grtz,

Kris

Hi Kris,

Thanks for this additional information.

If I understand correctly you are expecting that the fully working field found inside another field should be included in the field result of the outer field after update. I’m afraid this isn’t really how fields behave during field update. If you try the same construction in Microsoft Word and Aspose.Words you will see that only the plain text remains (and not a working field). This is the correct behavior.

Note that fields can be included in the field result but this only happens if you manually insert a field there and after field update these would be lost anyway. Perhaps the code in the previous version was incorrectly unlinking the fields which made a fully working field appear as the result, but I do not think this is the correct behavior.

If you have any further queries, please feel free to ask.

Thanks.

Hi,
You’re right, when converting it to text Word also removes the fields.
Yet as I used this behavior for post-processing, it’s pretty painful to see this behavior changed in Aspose.
Is there any change to add a property to change this behavior back to the old Aspose behaviour?
Or do you got another solution for post-processing?
I use Fields to find some places in the document back and change some behavior:
- For instance to find the table which has been created by aspose (TableStart) so I could remove empty rows.
(In pre-processing I add a commentfield with specific text so I can find it back in post-processing to remove empty rows)
- Another function I added is a repeater (TableStart with parameters for separator and end-separator)
In pre-processing I add commentfields on specific places to know where it starts, ends and where all separators must be included when not empty
In post-processing, I search these fields so I know where a part ended and can combine them with the right separator. Here I also ignore the empty ones …
Kind regards,
Kris

Hi Kris,

Thanks for this additional information.

I’m afraid I couldn’t quite reproduce your issue on my side. Could you please attach:

  • A sample template document which reproduces the issue
  • The output after executing the code using the old version of AW
  • The output after executing the code using the new version of AW.
  • Any documents related to the other two points in your previous post

I will then take a closer look into this for you.

Thanks,