We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

MergeField field codes seemingly can not contain two formatting codes

We have created a merge field event handler like the following:

 Private Sub ApplyListFormatOptionsEvent(sender As Object, args As MergeFieldEventArgs)
            'Bullet / unordered list options
            If args.CurrentMergeField.FieldCode.Contains(FIELD_FORMATTING_CODE_BULLETS_SQUARE) Then
                args.Text = args.Text.Replace("<ul>", "<ul style=""list-style-type: square"">")
            End If
            If args.CurrentMergeField.FieldCode.Contains(FIELD_FORMATTING_CODE_BULLETS_CIRCLE) Then
                args.Text = args.Text.Replace("<ul>", "<ul style=""list-style-type: circle"">")
            End If
            If args.CurrentMergeField.FieldCode.Contains(FIELD_FORMATTING_CODE_BULLETS_NONE) Then
                args.Text = args.Text.Replace("<ul>", "<ul style=""list-style-type: none"">")
            End If

            'Numbered / ordered list options
            If args.CurrentMergeField.FieldCode.Contains(FIELD_FORMATTING_CODE_NUMBERLIST_ROMAN_UPPER) Then
                args.Text = args.Text.Replace("<ol>", "<ol type=""I"">")
            End If
            If args.CurrentMergeField.FieldCode.Contains(FIELD_FORMATTING_CODE_NUMBERLIST_ROMAN_LOWER) Then
                args.Text = args.Text.Replace("<ol>", "<ol type=""i"">")
            End If
            If args.CurrentMergeField.FieldCode.Contains(FIELD_FORMATTING_CODE_NUMBERLIST_LETTERED_UPPER) Then
                args.Text = args.Text.Replace("<ol>", "<ol type=""A"">")
            End If
            If args.CurrentMergeField.FieldCode.Contains(FIELD_FORMATTING_CODE_NUMBERLIST_LETTERED_LOWER) Then
                args.Text = args.Text.Replace("<ol>", "<ol type=""a"">")
            End If
        End Sub

.. and added it like this: AddHandler document.MailMerge.MergeField, AddressOf ApplyListFormatOptionsEvent

It works great, unless we try having a merge field that would have two field formatting codes in the end, like {MERGEFIELD  ProjectDescription \circlebullets \romanupper}. Those merge fields seem to not be recognised by the MailMerge at all, or at least they will not call any event nor will there be a printed record.
Is there some notation we are using wrongly, or is that an actual bug?

4 Replies

VR Vijay Ramachandran Syncfusion Team January 16, 2019 09:33 AM UTC

Hi Alexander,

Thank you for contacting Syncfusion support.

Yes, you can use multiple merge field formatting codes, but you have to add “\*” as a prefix of the formatting token. Please find the modified field code from below and let us know if it helps.
Old Field Code 
New Field Code 
MERGEFIELD  ProjectDescription \circlebullets \romanupper 
MERGEFIELD  ProjectDescription \* circlebullets \* romanupper 

You can find the template document from below and let us know if it helps.

Vijay R

AK Alexander Khounani January 16, 2019 10:23 AM UTC

Hello Vijay,

sadly, this does not work with the provided template. (I tested it with keeping the constants as "\circlebullets", checking for that format, as well as with changing them to and checing for "circlebullets" and so on).  Again no value is exported (and the mergefield event is never reached in code) with two of them, but with one of them it works fine.

AK Alexander Khounani January 16, 2019 10:29 AM UTC

I got it to work by changing the field from your provided template from {MERGEFIELD ProjectDescription \* circlebullets  \* romanupper \* MERGEFORMAT} to {MERGEFIELD ProjectDescription \* circlebullets  romanupper \* MERGEFORMAT}, removing the second \*.

DB Dilli Babu Nandha Gopal Syncfusion Team January 17, 2019 03:40 PM UTC

Hi Alexander, 

We are glad to know that the reported issue has been resolved at your end. Please let us know if you need any further assistance on this. 

Dilli babu. 

Live Chat Icon For mobile
Up arrow icon