facebooktwittermenuarrow-up

GemBox Support Forum

Showing different paragraphs using IF Fields

Hi,

I am trying to implement IF FIELDS in a Word template. I am trying to show on word block if a merge field equals to “yes” and another if not:

{IF “«MyField1»”=“yes”} {Photo
«Picture:MyPicture»}

{Justification (Insurance)

«MyField2»}

Is it possible? Or does this feature only allows to perform the IF on 2 MERGED FIELDS?

Thanks,
Omid.

Hi Omid,

Unfortunately, you cannot use images inside the IF field, the evaluation currently supports only simple IF expressions.

Also, the current content model doesn’t support block-level elements inside the Field element.

Note that we plan to address these two limitations in the future, but at the moment I’m afraid I cannot say when exactly that will be.

Regards,
Mario

Thanks Mario for your answer. I will then wait for until it is implemented because supporting picture and word blocks inside the IF block is really important for business apps.

Thanks,
Omid.

Hi Mario,

I really need to implement a feature in my product that relies on the ability of Gembox Document library to handle IF THEN clauses with a block inside the IF and the THEN clause. And the block should contain anything including picture of course.

I am surprised that none of your customers have ever needed this feature. Is is possible to include this feature in a short term release? Then I will upgrade my bundle.

Thanks a lot,
Omid.

Hi Omid,

Yes, this feature was requested, but I’m afraid that currently, we’re working on some other features with greater priority (more users requested them).

For now as a workaround, you could consider creating a merge range that would conditionally end up being removed. For example, you could have a single field inside the range that would be merged when your condition is true, and not merged when it is false. That way the MailMergeClearOptions.RemoveEmptyRanges would delete your range when needed.

I hope this helps.

Regards,
Mario

Hi Mario,

I need to generate a word document containing custom fields with HTML formatting and where I also need to remove empty merged field. I thus tested MailMergeClearOptions as you recommened.

But I am experiencing weird issue when using MailMergeClearOptions with some of the options.
When using: document.MailMerge.ClearOptions = MailMergeClearOptions.RemoveUnusedFields | MailMergeClearOptions.RemoveEmptyRanges my generated word document contains my HTML fields but didn’t remove the empty fields.

When I set ClearOptions with all the options, it removes my empty fields (which is good) but I also removes all the custom HTML fields content:
document.MailMerge.ClearOptions = MailMergeClearOptions.RemoveUnusedFields | MailMergeClearOptions.RemoveEmptyParagraphs | MailMergeClearOptions.RemoveEmptyRanges | MailMergeClearOptions.RemoveEmptyTableRows;

I also purchased the upgrade package so I use the latest binaries.

Is this a bug?
Thanks,
Omid.

Hi Omid,

Please send us a small Visual Studio project that reproduces your issue so that we can investigate it.

Regards,
Mario