Field Name Mapping

There are certain events and operations in the UI Events Framework which accept field names of an object or record and perform certain operations or listen to certain events.

Field level operations and events such as the FieldValueChange event, the GetFieldValue operation, and the SetFieldValue operation require field names' details contained in an object or record. An object's field name details can be obtained using the following API:

# metadata of a specific <object>
curl -X GET -u username:password https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/<object>/describe

Here are some examples of API usage for ServiceRequest, Case and Contact objects:

# serviceRequest object
curl -X GET -u username:password https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/serviceRequests/describe

# case object
curl -X GET -u username:password https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/cases/describe

# contact object
curl -X GET -u username:password https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/contacts/describe

A screenshot of the response object detail

Here the metadata of all objects:

# metadata of all the objects' names with field details
curl -X GET -u username:password https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/describe
All fields must be mapped using the following format:
ObjectType.FieldName
eg: ServiceRequest.Title
As an example, an order to subscribe or perform certain operations on SR Title form, one must pass the field name as ServiceRequest.Title in the event, operation request object.
Note: As part of the current release of ui-events-framework, we only support simple and LOV fields. Complex fields is supported in the coming releases.

Get Field Value operation

This operation is use to fetch the current value of a field of a particular Record or Object (for example, to get the current value of the Title field of SR). This is a record level operation and thus the user must call the Publish API on top of record context ito perform this operation.

The following code sample shows an example in Typescript for publishing GetFieldValue operation where field names are passed.
/// <reference path="uiEventsFramework.d.ts"/> 
    const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID', 'v1');
    const tabContext: ITabContext = await frameworkProvider.getTabContext();
    const recordContext: IRecordContext = await tabContext.getActiveRecord();
    const requestObject: IGetFieldValueOperationRequest = (frameworkProvider.requestHelper.createPublishRequest('cxEventBusGetFieldValueOperation') as IGetFieldValueOperationRequest);
    requestObject.setFields(['ServiceRequest.Title', 'ServiceRequest.ProblemDescription']);
    
    recordContext.publish(requestObject).then((message) => {
        const response = message as IGetFieldValueResponse;
        const titleFieldValue = response.getResponseData().getField('ServiceRequest.Title').getValue();
        const problemDescriptionValue = response.getResponseData().getField('ServiceRequest.ProblemDescription').getValue();
        // custom code
    }).catch((error: IErrorData) => {
        // custom code
    });
The following code sample shows an example in JavaScript for publishing GetFieldValue Operation where field names are passed.
const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID', 'v1');
    const tabContext = await frameworkProvider.getTabContext();
    const recordContext = await tabContext.getActiveRecord();
    const requestObject = frameworkProvider.requestHelper.createPublishRequest('cxEventBusGetFieldValueOperation');
    requestObject.setFields(['ServiceRequest.Title', 'ServiceRequest.ProblemDescription']);
    recordContext.publish(requestObject).then((response) => {
        // custom code
        const titleFieldValue = response.getResponseData().getField('ServiceRequest.Title').getValue();
        const problemDescriptionValue = response.getResponseData().getField('ServiceRequest.ProblemDescription').getValue();
    }).catch((error) => {
        // custom code
    });

Set Field Value operation

This operation is used to update the value of a particular field of a particular record, object (For example, to update the Title field of SR). This is a record level operation and thus the user must call the publish API on top of record context to perform this operation.

The following code sample shows an example in Typescript for publishing SetFieldValue operation where field names are passed.
/// <reference path="uiEventsFramework.d.ts"/> 
    const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID', 'v1'); 
    const tabContext: ITabContext = await frameworkProvider.getTabContext();
    const recordContext: IRecordContext = await tabContext.getActiveRecord();
    
    const requestObject: ISetFieldValueOperationRequest = (frameworkProvider.requestHelper.createPublishRequest('cxEventBusSetFieldValueOperation') as ISetFieldValueOperationRequest);
    requestObject.field().setValue('ServiceRequest.Title', 'New Title');
    requestObject.field().setValue('ServiceRequest.ProblemDescription', 'New Problem Description');
    
    recordContext.publish(requestObject).then((message) => {
        const response = message as ISetFieldValueResponse;
        // custom code
    }).catch((error: IErrorData) => {
        // custom code
    });
The following code sample shows an example in JavaScript for publishing SetFieldValue Operation where field names are passed.
const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID', 'v1');
    const tabContext = await frameworkProvider.getTabContext();
    const recordContext = await tabContext.getActiveRecord();
    
    const requestObject = frameworkProvider.requestHelper.createPublishRequest('cxEventBusSetFieldValueOperation');
    requestObject.field().setValue('ServiceRequest.Title', 'New Title');
    requestObject.field().setValue('ServiceRequest.ProblemDescription', 'New Problem Description');
    
    recordContext.publish(requestObject).then((message) => {
        // custom code
    }).catch((error) => {
        // custom code
    });