Get Field Value Operation

This operation is used to fetch the current value of a field of a particular Record or Object (such as, to get the current value of the Title field of SR). You can set multiple fields in the request object of this operation to fetch multiple fields in one getFieldValue operation. This is a record-specific operation.

The following code sample shows an example in TypeScript of 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:
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
    });