Conditional statement using IF…ELSE is not working properly if we check the the htmlFormat keyword using not equals operator.
Eg:
{ IF { MERGEFIELD htmlFormatDetails } <> “” " INSIDE IF: {MERGEFIELD htmlFormatDetails } " “INSIDE ELSE: {MERGEFIELD htmlFormatDetails }” }
Here, if the content of the htmlFormatDetails is “ABCD 1234 QWER”, this particular field is returning only the 1234 i.e. the 2nd content of the text.
if the content of the htmlFormatDetails is "1234 QWER ABCD ", this particular field is returning QWER
But if I only put «htmlFormatDetails» i.e. { MERGEFIELD htmlFormatDetails }, all the respective values will be returned.
Also, if I check the conditional statement for the normal keyword (that is without htmlFormat) then it works perfectly.
i.e. { IF { MERGEFIELD details } <> “” " INSIDE IF: {MERGEFIELD htmlFormatDetails } " “INSIDE ELSE: {MERGEFIELD htmlFormatDetails }” }
Here, as were are checking the normal details keyword, it works perfectly.
Also, if I check the conditional statement using other values except the not equals then it works perfectly.
i.e. { IF { MERGEFIELD age } < “18” " INSIDE IF: {MERGEFIELD htmlFormatDetails } " “INSIDE ELSE: {MERGEFIELD htmlFormatDetails }” }
Here, as were are checking the < operator with “18” value, it works perfectly.
The only issue we are facing currently is when the htmlFormatted keyword is checked with not equals to empty.
Note: We are currently using Aspose Word 20.2
Code Snippet:
if ((e.getFieldName())?.startsWith(‘htmlFormat’)) {
if(!e.getFieldValue().equals(’<<’+e.getFieldName()+’>>’)){
mBuilder.moveToMergeField(e.getFieldName());
if(e.getFieldValue()) {
mBuilder.insertHtml((String) e.getFieldValue(),true)
}
}
}
Could you please analyze?