Save Record Operation

This operation is used to save an open Record or Object in the UI. (such as save an SR form from the Edit page or save an SR from Create page).

The response of SaveRecordOperation gives information about the oldObjectId and actual object identifier after saving. This response is similar to the response from OnAfterSave event subscription response. The old identifier and new identifier is different only when a save event happens on a new object. For example, while creating a new object UEF assigns a -ve identifier to it, and this -ve identifier is received in the ContextOpen event's subscription response. After saving, this object is assigned an actual identifier from the database.
Note: The SaveRecord Operation is an operation publishable from RecordContext level.
The following code sample shows an example in TypeScript for publishing SaveRecord 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: IOperationRequest = frameworkProvider.requestHelper.createPublishRequest('cxEventBusSaveRecordOperation');
    recordContext.publish(requestObject).then((message) => {
        const response = message as ISaveRecordResponse;
        const oldObjectId = response.getResponseData().getOldObjectId();
        const newObjectId = response.getResponseData().getObjectId();
        const objectType = response.getResponseData().getObjectType();
        // custom code
    }).catch((error: IErrorData) => {
        // custom code
    });
The following code sample shows an example in JavaScript for publishing SaveRecord 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('cxEventBusSaveRecordOperation');
    
    recordContext.publish(requestObject).then((response) => {
        // custom code
        const oldObjectId = response.getResponseData().getOldObjectId();
        const newObjectId = response.getResponseData().getObjectId();
        const objectType = response.getResponseData().getObjectType();
    }).catch((error) => {
        // custom code
    });