Listen to the OnAfterSave Event

The OnAfterSave event is triggered after a Task or Appointment record is saved successfully. Use this event to perform actions that require confirmation that the save operation completed.

The event payload is available in event.data. For newly created records, event.data.newObjectId contains the ID of the saved record.

define([
  'vb/action/actionChain',
  'vb/action/actions',
  'vb/action/actionUtils',
], (
  ActionChain,
  Actions,
  ActionUtils
) => {
  'use strict';

  class recordLevelEventListener extends ActionChain {

    /**
     * @param {Object} context
     * @param {Object} params
     * @param {{data:any,eventName:string,recordType:string}} params.event
     */
    async run(context, { event }) {
      const { $page, $flow, $application, $base, $extension, $constants, $variables, $modules } = context;

      switch (event.eventName) {
        
        case 'OnChildRecordOpen': {
          
          const callGetRecordByContext = await $modules.uiEventsFramework.getRecordByContext($variables.uefContext,
            { objectId: event.data.objectId, objectType: event.data.objectType });
            
            const callRegisterEventsForRecordLevelEvent = $modules.uiEventsFramework.registerEventsForRecordLevelEvent([
                'FieldValueChange',
                'OnBeforeSave',
                'OnAfterSave',
                ], callGetRecordByContext.response);

          break;
        }
        case 'OnAfterSave':   
           if (event.data.objectType === 'Task') {                       
              await Actions.fireNotificationEvent(context, { summary: 'OnAfterSave Event', message: 'New Object Id: ' + event.data.newObjectId, displayMode:    'transient', type: 'info', });         
           }
        break; 

  
      }


      

    }
  }

  return recordLevelEventListener;
});
Property Description
OnAfterSave Event triggered after a Task or Appointment record is saved successfully.
event.eventName Identifies the received event. Use it to handle the OnAfterSave event.
event.data Contains details about the completed save operation.
event.data.newObjectId ID of the newly created Task or Appointment record.