RecordContext
RecordContext enables you to listen to events and operations related to an object. For instance, you can listen to a field value change, on before save event, ON after save event, and so on.
Supported Events
| Event Name | Description | Example |
|---|---|---|
| FieldValueChange | Started when a field value change, such as an SR title field change, occurs. | Field Value Change Event |
| OnBeforeSave | Started before start of the REST API request to commit the data to the server. The end-user can perform asynchronous operations in this callback or cancel this event. This event can wait for an asynchronous operation to be completed. | OnBeforeSave Event |
| OnAfterSave | Started after a record is saved a in the VB application. For example, after saving an SR. | On After Save Event |
| OnDataLoad | Started when data is loaded. For example, after fetching an SR object data. | DataLoad Event |
| CustomEvent | Used to support any business specific custom events. | Subscribe Custom Events |
| OnBeforeSmartAction | Started before the execution of smart action. The end-user can perform asynchronous operations in this callback or cancel this event. This event can wait for an asynchronous operation to be completed. | OnBeforeSmartAction Event |
| OnAfterSmartAction | Started after a smart action is completed. | OnAfterSmartAction Event |
| OnBeforeMessageSend | This event will be fired before firing the REST API request to send message to recipients, from compose message smart action. End-user can perform asynchronous operations in this callback and allow or cancel this message send process. This means, this event can wait for an asynchronous operation to be completed. | OnBeforeMessageSend |
| OnAfterMessageSent | This event is a notify event which will be fired after successfully sending message to recipients from Compose Message Smart Action. | OnAfterMessageSent Event |
Supported Operations
| Operation Name | Description | Example |
|---|---|---|
| GetFieldValue | Used to fetch the current value of a field. For instance, us it to get the current value of the Title field of an SR. | Publish GetFieldValue operation. |
| Save Record | Used to save an open record. For instance, use it to save an SR form from an edit page or save an SR from create form. | Publish Save Record operation. |
| SetFieldValue | Used to update the value of a particular field. For instance, use it to update the Title field of an SR. | Publish SetFieldValue operation. |
| CustomEvent | Used to support any business specific custom events. | Publish CustomEvent operation. |
| GetFieldsInUI | Used to fetch the list of fields in the rendered dynamic form. | Publish GetFieldsInUI operation. |
Supported Methods
| Method Name | Description |
|---|---|
| subscribe | Subscribe to an event from the Fusion application. For example, the Field Value Change Event |
|
subscribeOnce |
Subscribe once to an event from fusion application's record context, once the event is fired, the subscription disposes. For example: Field Value Change Event. |
| publish | Publish an operation in record context, for example: SetFieldValue operation, GetFieldValue operation. |
| dispose | Disposes the recordContext. |
| getSupportedEvents | Returns events supported by that record context as an array, for example: GetFieldValue operation, SetFieldValue operation, Save Record operation, Subscribe Custom Events. |
| getSupportedActions | returns actions supported by that record context as an array, for example: DataLoad Event, OnBeforeSave Event, On After Save Event, Field Value Change Event, Subscribe Custom Events. |
| getRecordType | Returns a type of record, for example: ServiceRequest, or Case. |
| getRecordId | Returns the record ID. For a record context of a record not created yet, the ID will be a negative number. |
You can get the reference of RecordContext only by calling getActiveRecord() API on top of TabContext object which could be either a browser-TabContext or an MSI-TabContext. Apart from getActiveRecord API, you can get the RecordContext object as a response of ContextOpen event subscription.