MailMerge Issue with NextIf - SKIPIF Doesnt Support

Since SkipIf Field doesn’t support in ASPOSE. I tried to use NextIf Field with MailMerge functions.

I want to skip some records while MailMergeWithRegions. Please refer attached apps, where in XML datasource I have 3 Orders and I want to skip second order with Number = 10. But I found only one order in the output. Also when I tried to Skip last order it gave me exception.

Also as per the following from Microsoft:

http://office.microsoft.com/en-us/word-help/field-codes-nextif-field-HP005186175.aspx

Hi there,
Thanks for attaching your template here.
There are two reasons why this issue is occuring. The first is because the part of the NEXTIF field where you check the current Number being merged is plain text instead of a proper field. e.g it looks like this { NEXTIF Number=10 } where it should be like { NEXTIF {MERGEFIELD Number}=10 }.
The second issue occurs because there are no spaces around the equal sign. This causes issues for Microsoft Word as well. Your field needs to look like this { NEXTIF {MERGEFIELD Number} = 10 }.
After fixing these the output appears as expected. I have made the mentioned changes to the template and attached it here for you.
If you have any further queries, please feel free to ask.
Thanks,

Thanks for prompt reply.

But there is still an issue with NextIf function, if the condition fail for the last record in the table, MailMerge ExecuteWithRegions throw an exception, because it doesn’t have the next record available in the table.

Do you think its ASPOSE Words issue or that’s the correct behavior? Also when do you think SkipIf function will be supported by ASPOSE Words?

Hi there,
Thanks for this additonal information.
That’s a good question, it seems that the field is doing what it should as it’s attempting to merge the next record, but which doesn’t exist. I guess it would be better if NEXTIF would function so if it’s the last record in a database then no further merge is executed and no exception is thrown. I have logged this issue and you will be informed once it’s fixed.
In the mean time I suggest you avoid skipping any value at the end of your datasource. If you unsure if a value is at the end of the datasource you can still execute mail merge as you are but wrap the execute call in try and catch blocks and then ignore the exception thrown. There is still an issue as the output document will contain a blank “copy” of the region with unmerged fields included. This can be removed by including a bookmark in the region and using the code below. The BookmarksVisitor code can be found in this thread here. I have attached a sample template with bookmark included

// Execute nested mail merge with regions
try
{
    doc.MailMerge.ExecuteWithRegions(pizzaDs2);
}
catch (Exception e)
{
    doc.Accept(new BoookmarksVisitor(new DocumentBuilder(doc)));
    // Remove last section.
    Bookmark lastMergeRegion = testDoc2.Range.Bookmarks["MergeRegion_2"];
    lastMergeRegion.Text = "";
    lastMergeRegion.BookmarkStart.ParentNode.Remove();
}

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

We are having this same issue with NEXTIF only with a MUCH newer version (11.2.0.0). Is there any timeline on when this might be fixed?

Hi Mike,

Thanks for your inquiry.

I’m afraid this issue is postponed for the time being as there hasn’t been many requests for it and there are plenty of other issues that need tending to. We will let you know as soon as we begin development on this bug fix.

Thanks,

The issues you have found earlier (filed as WORDSNET-4284) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as WORDSNET-4285) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(35)