Skip to main content

Customers

The Customers module provides access to contextual information about the current customer when a widget is rendered within supported customer-related pages. Widgets can retrieve customer identifiers, classification details, and related metadata for use in validations, conditional logic, and UI extensions.

Events

Events

CUSTOMER_SAVED

This event is triggered after the customer record is successfully saved in your organization. You can use this event to perform post-save actions such as syncing data, triggering notifications, or updating external systems.

Supported Locations :
customer.creation.sidebar
Sample Code :
REQUEST DETAILS
ZFAPPS.extension.init().then(function(App) {
  App.instance.on('ON_CUSTOMER_SAVED').then(function(data) {

    var recordId = data && data.record_id;

    ZFAPPS.invoke('SHOW_NOTIFICATION', {
      type: 'success',
      message: 'Record saved successfully. Record ID: ' + recordId
    });

    console.log('Saved record ID:', recordId);

  }).catch(function(err) {
    console.error('Error:', err);
  });
});

ON_CUSTOMER_CHANGE

This event is triggered whenever a supported field value is changed within the customer form. The event is fired based on the configured supported keys, allowing your widget to react dynamically to user input.

Supported Locations :
customer.creation.sidebar
Sample Code :
REQUEST DETAILS
ZFAPPS.extension.init().then(function(App) {
  App.instance.on('ON_CUSTOMER_CHANGE').then(async function() {

    var record = await ZFAPPS.get('customer');
    record = record?.['custom_fields'];

    if (record.cf_special_flag) {
      ZFAPPS.invoke('SHOW_NOTIFICATION', {
        type: 'success',
        message: 'Special option selected. Please review additional details before saving.'
      });
    }

  }).catch(function(err) {
    console.error('Error:', err);
  });
});

ON_CUSTOMER_PREVIEW

This event is triggered when the preview of a customer record is opened in your organization. It allows your widget to access record data and render contextual information during the preview phase.

Supported Locations :
customer.details.sidebar
Sample Code :
REQUEST DETAILS
ZFAPPS.extension.init().then(function(App) {
  App.instance.on('ON_CUSTOMER_PREVIEW').then(async function() {

    var record = await ZFAPPS.get('customer');
    record = record?.['custom_fields'];

    if (record.cf_priority_level === 'High') {
      ZFAPPS.invoke('SHOW_NOTIFICATION', {
        type: 'error',
        message: 'This record is marked as High Priority.'
      });
    }

  }).catch(function(err) {
    console.error('Error:', err);
  });
});

ON_CUSTOMER_PRE_SAVE

This event is triggered just before the customer record is saved in your organization. It allows your widget to validate data, modify field values, or perform custom checks before the save operation is completed.

Supported Locations :
customer.creation.sidebar
Sample Code :
REQUEST DETAILS
ZFAPPS.extension.init().then(function(App) {
  App.instance.on('ON_CUSTOMER_PRE_SAVE').then(async function() {

    var record = await ZFAPPS.get('customer');
    record = record?.['custom_fields'];

    if (record.cf_approval_required && !record.cf_approval_notes) {

      await ZFAPPS.invoke('SHOW_NOTIFICATION', {
        type: 'error',
        message: 'Approval notes are required when Approval Required is selected.'
      });

      return {
        prevent_save: true
      };
    }

  }).catch(function(err) {
    console.error('Error:', err);
  });
});

ON_CUSTOMER_PAGE_LOAD

This event is triggered when the widget is loaded for the first time on the customer page. You can use this event to initialize data, fetch required resources, or set up the initial state of your widget.

Supported Locations :
customer.creation.sidebar
Sample Code :
REQUEST DETAILS
ZFAPPS.extension.init().then(function(App) {
  App.instance.on('ON_CUSTOMER_PAGE_LOAD').then(async function() {
    // Set default value for a custom field
    await ZFAPPS.set('customer.cf_priority_level', 'Normal');

    ZFAPPS.invoke('SHOW_NOTIFICATION', {
      type: 'success',
      message: 'Default priority level has been set to Normal.'
    });
  }).catch(function(err) {
    console.error('Error:', err);
  });
});