ASK field errs when Ask ref named the same as value

When I use the following ASK - the Aspose object throws an error. In ASPOSE.Words v11.0 it throws a stackoverflow error and in v11.11 it throws an InvalidOperationException.

{ASK JUNKED "Is Order JUNKED or SIGNED?" \d "JUNKED" \o}{IF {REF JUNKED} = "JUNKED" "JUNKED" "NOT JUNKED"}

When I pass any other field value (except JUNKED) it does not error. BTW, the IFcondition is part of the problem - without it, the code runs fine.

As a workaround we’re choosing field names (REF) that won’t also be the answer (ie. JUNKED and JUNKED).

Attached are the input file and code file.

kind regards,
linda

Hi linda,

Thanks for your inquiry.

I have worked with your document and have found that there is a bookmark in your document with name “JUNKED”. In your code, you are adding another bookmark with same name “JUNKED” that is the reason you are getting the exception. To avoid this issue, please remove bookmarks which already exists or change the name of bookmark as shown in following code snippet.

Hope this answers your query. Please let us know if you have any more queries.

//Insert new field code and field value
builder.MoveTo(fieldSeparator);
builder.Write(fieldCode);
builder.MoveTo(fieldEnd);
// We should surround the value with bookmark.
string bookmarkName = match.Groups["bookmark"].Value + "_new";
builder.StartBookmark(bookmarkName);
builder.Write(fieldValue);
builder.EndBookmark(bookmarkName);