Mailmerge and conditions

I’m having problems with conditions and the mailmerge function

this
is a piece of the document (field codes toggled)
MERGEFIELD
TableStart:Employee
MERGEFIELD street MERGEFIELD hid
IF “{
MERGEFIELD box }” ="" “” “{ MERGEFIELD box }”
MERGEFIELD
TableEnd:Employee

which restults as this
test 25
{ MERGEFIELD box }

I’m executing the mailmerge with the ExecuteWithRegions method (for every table in a dataset).
After the mailmerge I do an updateFields

Hello

Thanks for your inquiry. Could you please attach your input document here and show me the code, which will help me to reproduce the problem on my side? I will investigate the problem and provide you more information.

Best regards,

Code:

foreach (DataTable table in DsData.Tables)
{
//Controle of er data in een bepaalde tabel bestaat
foreach (DataRow row in table.Rows)
{
for (int i = 0; i < table.Columns.Count; i++)
{
if (!string.IsNullOrEmpty(row[i].ToString()))
{
merge = true;
}
}
}

if (table.Rows.Count > 0 && merge)
{
workDoc.MailMerge.ExecuteWithRegions(table);
workDoc.MailMerge.Execute(table);
}
}

workDoc.UpdateFields();
workDoc.MailMerge.DeleteFields();

Hi Sebastian,

Currently the syntax to your nested field is correct but they aren’t working because the merge fields inside your if statement aren’t actually fields, they are just plain text. To get it to work you should delete that plain text inside the if statement and replace them with real merge fields by either going Insert -> Quick Parts -> Field and scroll down to merge field, or you can instead just copy and paste the merge field from one of the other fields in the document making sure to include the swirly brackets when you copy as well “{“.

I can also e-mail you the corrected document if you like.

One thing though, currently the logic in your if statement seems a bit redundant. You are saying if the merged field is empty then replace it with empty string, which is what it already is. Then you are saying if the merged text is not empty than replace the text with the same merge field, but this is still the same text already there without the If field.

Thanks,

Adam

Thank you, that did it. I thought just typing in the fields would do it. I never really noticed the special brackets.