CAPTION Function (Form)

Microsoft Dynamics Nav 2009

Returns the current caption of an object as a string and sets a new caption for the object.


[CurrCaption :=] Form.CAPTION([NewCaption])

Parameters

NewCaption

Type: Text or code

The new caption for the object.

Type: Text or code

The current caption, as a string.

CAPTION returns the current caption or sets the caption of an object. CAPTION first looks for a CaptionML Property. If it finds one, it returns the caption portion of the CaptionML property. If it does not find one, it looks for a Caption Property. If that also fails, it will use the Name Property. This means that CAPTION includes multilanguage functionality.

When CAPTION is used to set a new caption for an object, this new caption is not stored with the object. It is only effective for the instance of the object where it is set.

For tables and fields in tables, you must use the TABLECAPTION Function (Record) or the FIELDCAPTION Function (Record).

This example shows how to use the CAPTION function. This example assumes that the current form is form 42, Sales Order, and the CaptionML property of this form is ENU=Sales Order. This example requires that you create the following variables and text constants in the C/AL Globals window.

Variable name DataType Length

OriginalCaption

Text

1024

NewCaption

Text

1024

CaptionString

Text

1024

Text Constant ENU Value

Text000

The original caption was %1.

Text001

The new caption is %1.

OriginalCaption := CurrForm.CAPTION;
MESSAGE(Text000, OriginalCaption);
CaptionString := ' Some New Caption';
CurrForm.CAPTION(CaptionString);
NewCaption := CurrForm.CAPTION;
MESSAGE(Text001, NewCaption);

The message windows could display the following:

The original caption was Sales Order.

The new caption is Some New Caption.

Community Additions

ADD
Show: