Conditional Merge Field Issue - Error! Unknown op code for conditional


We have just had this same error occur but there are no spaces in merge field names or values.

I’ve found that if the condition contains a merge field and there is no space between it and the equals sign, then this error is produced after an Aspose mail merge.

EDIT: Word doesn’t care and if i “update field” in word the condition is evaluated correctly and without error.

{ IF { MERGEFIELD Value }= "Y" "Yes" "No" }


{ IF { MERGEFIELD Value } = "Y" "Yes" "No" }

Attached is an example template and resulting document where you can see this in action.

We are on Aspose.Words 9.3.0.


Hi Matthew,
Thanks for your inquiry.
I have tested your documents and was unable to reproduce any issue when using simple mail merge. I was however able to reproduce the issue when calling doc.UpdateFields() after merging. Please note that calling UpdateFields after mail merge is not necessary as any affected fields related to the merge fields are updated during the mail merge process. Interestingly Aspose.Words updates the field properly during mail merge but displays an error when UpdateFields is invoked manually.
However I do not believe this to be a bug, if I update the field in question in MS Word it does not produce any error, but if you look at the result it is actually incorrect, you can pass it any value, as well as one which is not equal to “Y” and it will still continue to display “Y” instead of “Yes” or “No”. This seems to point to the field having improper syntax that not even MS Word properly understands. My suggestion is to avoid using this sort of syntax in your conditional fields.
I have linked this issue to be fixed in a future version as I suppose it would be nice to update these fields with and without a space, but please note the issue may be closed as “Not A Bug” instead.

Very interesting…

I went a bit further and concur that the issue does indeed occur in word but only where:

  1. The is no space between left side of the equality and the equals sign, and
  2. The left side of the operation is not quoted

EDIT: Testing this on the right side of the equality produces the same rubbish.

See the attached documents where ConditionalUF.docx shows true and false tests with a combination of space and quotes or not. You can see that it is only the two meeting the above conditions that have the error.

Note, yes we were calling UpdateFields() after the mail merge and it is nice to know we don’t need to so will remove it…

Conditional.docx is the same as ConditionalUF.docx but without the Aspose call to UpdateFields().

In both cases, if you “Update Fields” from within Word, the value reverts to the rights side of the equality.

We are satisfied that our clients need to correctly format IF statements, but find it interesting that your mail merge correctly evaluates the conditions but your update fields method does not. We will remove the call to update fields so should not need to utilise it anyway.


Hi Matthew,
Thanks for posting your additional findings here. I have included this further information in the logged issue. It’s great that the issue is resolved for you. I suppose your client’s can still use those types of conditional fields as long as they don’t use UpdateFields, although as we know they should consider fixing them as MS Word won’t update them properly.
If you have any further queries, please feel free to ask.

We have the same issue but I was told we have to call UpdateFields because some of our documents have table of content fields, and the Table of Contents does not get updated after all the merge fields are processed unless the UpdateFields is called at the end. Is this true or can I also remove the UpdateFields method.

If you are executing a mail merge then there is no need to update fields after executing a mail merge because mail merge is a kind of field update and automatically updates all fields in the document.
Best Regards,