Set Field Value Operation
This operation is to update the value of a particular field of a particular Record or Object (for instance, updating the Title field of SR). This is a record-level operation; so, you must call the publish API on top of the record context.
The following code sample shows an example in TypeScript of 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:
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
});