FieldMergingArgsBaseFieldValue Property

Gets or sets the value of the field from the data source.

Namespace:  Aspose.Words.MailMerging
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.8.0


public Object FieldValue { get; set; }

Property Value

Type: Object


This property contains a value that has just been selected from your data source for this field by the mail merge engine. You can also replace the value by setting the property.


Shows how to use data source value of the field.
public void FieldFormats()
    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);
    builder.InsertField("MERGEFIELD TextField \\* Caps", null);
    builder.Write(", ");
    builder.InsertField("MERGEFIELD TextField2 \\* Upper", null);
    builder.Write(", ");
    builder.InsertField("MERGEFIELD NumericField \\# 0.0", null);

    builder.Document.MailMerge.FieldMergingCallback = new FieldValueMergingCallback();

        new string[] { "TextField", "TextField2", "NumericField" },
        new object[] { "Original value", "Original value", 10 });

    Assert.AreEqual("New Value, New value from FieldMergingArgs, 20.0", doc.GetText().Trim());

private class FieldValueMergingCallback : IFieldMergingCallback
    /// <summary>
    /// This is called when merge field is actually merged with data in the document.
    /// </summary>
    void IFieldMergingCallback.FieldMerging(FieldMergingArgs e)
        switch (e.FieldName)
            case "TextField":
                Assert.AreEqual("Original value", e.FieldValue);
                e.FieldValue = "New value";
            case "TextField2":
                Assert.AreEqual("Original value", e.FieldValue);
                e.Text = "New value from FieldMergingArgs";   // Should suppress e.FieldValue and ignore format
                e.FieldValue = "new value";
            case "NumericField":
                Assert.AreEqual(10.0d, e.FieldValue);
                e.FieldValue = 20;

    void IFieldMergingCallback.ImageFieldMerging(ImageFieldMergingArgs e)
        // Do nothing

See Also