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
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
ObjectType.FieldName
eg: ServiceRequest.Title
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.
/// <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
});
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.
/// <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
});
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
});