UI Definition in HTML and TypeScript: TypeScript Decorators

In this topic, you can find a reference list of the TypeScript decorators available for MYOB Acumatica forms.

columnConfig

You use the columnConfig decorator to specify the configuration options for a table column, as shown in the following code example. For descriptions of the options, see Table (Grid): Reference Information.
export class FALocationHistory extends PXView {
    @columnConfig({ hideViewLink: true })
    FAAccountID: PXFieldState;
}

The decorator can be used for the properties of view classes.

featureInstalled

You use the featureInstalled decorator to specify the feature that must be installed to use this form. You specify the feature by using the name of the class that defines this feature in the source code, as shown in the following code.
@featureInstalled(
  'PX.Objects.CS.FeaturesSet+outlookIntegration')
export class OU201000 extends PXScreen {
}

The decorator can be used for screen classes (that is, the classes that extend the PXScreen class).

graphInfo

You use the graphInfo decorator to specify the information about the graph of the form, as shown in the following example.

@graphInfo({
  graphType:'PX.Objects.GL.AccountHistoryEnq',
  primaryView:'Filter'})
export class GL401000 extends PXScreen {
}

You can use any of the following parameters of the decorator.

Parameter Description
bpEventsIndicator

Indicates (if set to true) that the Business Events and Notifications commands in the Settings menu on the form title bar are available.

The following analog is available in ASPX: BPEventsIndicator of PXFormView.

graphType

Required. Specifies the graph type.

The following analog is available in ASPX: TypeName of PXDataSource.

hideFilesIndicator

Hides (if set to true) the Files button on the form title bar, even if it is available for the screen.

The following analog is available in ASPX: FilesIndicator of PXFormView.

hideNotesIndicator

Hides (if set to true) the Notes button on the form title bar, even if it is available for the screen.

The following analog is available in ASPX: NoteIndicator of PXFormView.

pageLoadBehavior

Specifies the load behavior for the page, which is defined by one of the following values of the PXPageLoadBehavior enum:

  • InsertRecord (default): A new record is inserted.

  • SearchSavedKeys: The record is restored by keys from the session.

  • PopulateSavedValues: The record is restored by filters from the session.

  • GoFirstRecord: The first record (sorted by key fields) is opened.

  • GoLastRecord: The last record (sorted by key fields) is opened.

The following analog is available in ASPX: pageLoadBehavior of PXDataSource.

primaryView

Required. Specifies the primary view of the graph.

The following analog is available in ASPX: PrimaryView of PXDataSource.

showActivitiesIndicator

Shows (if set to true) the Activities button on the form title bar. By default, the value is false.

The following analog is available in ASPX: ActivityIndicator of PXFormView.

showUDFIndicator

Shows (if set to true) the Manage User-Defined Fields command in the Settings menu on the form title bar. By default, the value is false.

udfTypeField

Specifies the field that is used on the Properties tab of the Edit User-Defined Fields (CS205020) form to define the category of records to which the settings in the table on the tab are applied.

The following analog is available in ASPX: UDFTypeField of PXDataSource.

The decorator is required for screen classes (that is, the classes that extend the PXScreen class).

gridConfig

You use the gridConfig decorator to specify the configuration options for a table on a form, as shown in the following code. For descriptions of the options, see Table (Grid): Reference Information.

@gridConfig({
  preset: GridPreset.Details,
  initNewRow: true,
  syncPosition: true,
  wrapToolbar: true,
  statusField: "Availability"
})
export class SOLine extends PXView {
}

The decorator can be used for view classes (that is, the classes that extend the PXView class).

handleEvent

You use the handleEvent decorator to mark a handler of a runtime event for the specified view, or a handler of a runtime event for the specified field.

The following event types are supported (see the CustomEventType enum).

Event Type Description
GetCellCss

Is invoked when the cell content has changed. You can implement an event handler to change the CSS for the cell.

The following code shows an example of a handler of the GetCellCss event.

@handleEvent(CustomEventType.GetCellCss,
  { view: 'Transactions', column: 'CuryLineAmt' })
getTransactionsCellCss(args: CellCssHandlerArgs):
  string | undefined {
    if (args?.selector?.rowIndex === 0 &&
        args?.selector?.cellValue > 1000) {
        // see static/custom.css
        return 'red-cell';
  }
  return undefined;
}
GetRowCss Is invoked when the row content has changed. You can implement an event handler to change the CSS for the row.

The following example shows the definition of a handler of the GetRowCss event.

@handleEvent(CustomEventType.GetRowCss,
  { view: 'Transactions' })
getTransactionsRowCss(args: RowCssHandlerArgs) {
    if (args?.selector?.rowIndex === 1) {
        // see static/custom.css
        return 'bold-row';
    }
 
    return undefined;
}
RowSelected Is invoked when the server has updated a row of the specified view.
ValueChanged Is invoked when a user has changed the value of the specified control.

headerDescription

You use the headerDescription decorator to specify that the value of the field is displayed in the header of the form, such as the customer ID on the Customers (AR303000) form. The following code shows an example of code that uses this decorator.

@headerDescription 
CustomerID: PXFieldState;

The decorator can be used for properties of view classes.

linkCommand

You use the linkCommand decorator to specify the action to be executed when a user clicks the link on the field. The following code shows an example of code that uses this decorator.

export class Contacts extends PXView {
    @linkCommand("ViewContact")
    DisplayName: PXFieldState;
}

The decorator can be used for the properties of view classes.

Note:
Currently, the decorator works only for the columns of a grid control. The only way to enable a link for a field that does not correspond to a column in a table is to set it up in the config of the field's control in HTML, as shown in the following example.
<field name="OrigRefNbr" 
    config-link-command.bind="'ViewOriginalDocument'">
</field>

localizable

You use the localizable decorator to mark a class with localizable messages or a localizable string, as shown in the following examples.

@localizable
export class Messages {
    static ExternalLink = "External Link:";
}
export class QpDacBrowserCustomElement {
    @localizable
    static NothingFoundMsg: string = 
      "No entries have been found for the {filter}";
}

placeAfterProperty

You use the placeAfterProperty decorator to indicate that the field should be placed after the specified field, as shown in the following example.

@placeAfterProperty("caseCD") 
ProjectId: PXSimpleSelectorState;

You should use this decorator only in the following cases:

  • If for the view class, the control in HTML does not have the list of fields specified and shows all fields of the view class
  • If the order of fields is important to the business logic because the server uses this order to update fields

The decorator is used for the properties of view classes in extensions.

placeAfterView

You use the placeAfterView decorator to indicate that the data view should be placed after the specified data view, as shown in the following example.

@placeAfterView("Filter")
export class GLSetup extends PXView {
}

The decorator is used for view classes (that is, the classes that extend the PXView class) in extensions.

placeBeforeProperty

You use the placeBeforeProperty decorator to indicate that the field should be placed before the specified field, as shown in the following example.

@placeBeforeProperty("caseCD") 
ProjectId: PXSimpleSelectorState;

You should use this decorator only in the following cases:

  • If for the view class, the control in HTML does not have the list of fields specified and shows all fields of the view class
  • If the order of fields is important to the business logic because the server uses this order to update fields

The decorator is used for properties of view classes in extensions.

placeBeforeView

You use the placeBeforeView decorator to indicate that the data view should be placed before the specified data view.

@placeBeforeView("Filter")
export class GLSetup extends PXView {
}

The decorator is used for view classes (that is, the classes that extend the PXView class) in extensions.

viewInfo

You use the viewInfo decorator to identify a property that corresponds to a data view of the graph.

You can use any of the following parameters of the decorator:

  • containerName: Specifies a user-friendly name of the container. This name is used as an object name during the configuration of particular functionality, such as workflows and import and export scenarios. If this value is not specified, the system displays the name of the data view as the object name.

    The following code shows an example of use of this decorator.

    export class GL301000 extends PXScreen {
     @viewInfo({containerName: 'Batch Summary'})
     BatchModule = createSingle(Batch);
    }
  • syncAlways: If the value is true, includes the data view in the list of views whose data is sent in the requests between the browser and the server. By default (if the value is false), only the data views whose data is visible to a user are included in this list. Setting of the value to true may be useful for service data views whose data is used for calculations on the form, such as calculation of visibility of a tab.

The decorator can be used for the properties of screen classes.