Skip to main content
Skip table of contents

Available API Functions

Each Web App Control Project contains the x4-webapp-api.d.ts and x4-webapp-api.js files in the Sources folder. The following functions are available for the X4API class declared in this files:


Function

Description

init(): Promise<boolean>;

Initializes the connection to the parent custom control component.

Return value:

  • Promise with a boolean value specifying whether the JavaScript API is supported by the current version of the web app
getPropertyDefinitions(): Promise<any[]>;

Return value:

  • Promise with an array value of property definitions
subscribeToDataModelChanges(func: (v: any) => void): string;

Developers can use this function to react to data model changes by setting the function to process incoming modifications.

Return value:

  • ID that can be used for the Unsubscribe function later

subscribeToPropertyChanges(propertyName: string, func: (v: object[]) => void): string;

Developers can use this function to react to property changes by setting the function to process incoming modifications.

Return value:

  • ID that can be used for the Unsubscribe function later
getPropertyValue(v: string): Promise<string>;

Return value:

  • Promise with a string representation  of a property value
getPropertyValidationErrors(v: string): Promise<string[]>;

Return value:

  • Promise with an array of validation messages (the array is empty if there are no errors)
setPropertyValue(n: string, v: string): void;Sets the property value by name.
unsubscribeDataModelChanges(sid: string): void;Terminates the subscription of data model changes by subscription ID.
getAllPropertyValues(): Promise<any>;

Return value:

  • Promise with all properties that are available in the component
unsubscribePropertyValueChanges(sid: string): void;Terminates the subscription of value changes by subscription ID.
setControlWidth(value: string): void;

Sets the desired width of the control.

Possible values:

  • CSS values for width/height (e.g. 150px, 33%, 73vw)
setControlHeight(value: string): void;

Sets the desired height of the control.

Possible values:

  • CSS values for width/height (e.g. 150px, 33%, 73vw)
getControlWidth(): Promise<any>;

Return value:

  • Promise with the height of the control
getControlHeight(): Promise<any>;

Return value:

  • Promise with the width of the control
getActions(): Promise<any>;

Return value:

  • Promise with the action name
executeAction(name: string, parameters?: any): Promise<any>;

Accepts the action name and an optional custom parameter array of the [ {key:'test', value:'test'}, ......  ] type.

Return value:

  • Promise with action response
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.