On this Page

    _mergeEmbedded

    (Merge only)

    String substitution in data fields

    Syntax

    _mergeEmbedded(text)

    Parameters

    text a text string with [fieldname] or [!autofield] placeholders to be replaced.

    Returned Value

    A new string with substituted data.

    Description

    This routine is a script equivalent of the [fieldname] and [autofield] substitution available in normal text labels. See the Auto/Embedded Fields section for a list of available [autofield] variables.

    _mergeEmbedded looks for substrings of the form [fieldname] and replaces them with the field's value from the current document. This function uses the same substitution logic as Merge embedded fields processing including [!pagenum], etc. If the text between the left and right square brackets is not a known name the text and square brackets are left unchanged in the text string.

    Example

    If the Field "LastName" has the value "Smith" and the Field "AccountNo" has the value "123456", then:

    merged = _mergeEmbedded("Dear Mr [LastName]:\n  re your account#[AccountNo]");
    // becomes "Dear Mr Smith:\n  re your account#123456"    

    Note that a potentially common usage of this facility is in scripts run at the Data Merged event. At that event, data values have not had embedded field substitution done yet. Hence one may want to use:

     merged = _mergeEmbedded(this._value);    

    to get the current field's value as it would be when embedded field substitutions (if any) has been done.

    See Also

    Auto/Embedded Fields
    _auto