Skip to main content

Vendors

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

Events

Events

VENDOR_SAVED

This event is triggered after the vendor 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 :
vendor.creation.sidebar
Sample Code :
REQUEST DETAILS
ZFAPPS.extension.init().then(function(App) {
  App.instance.on('ON_VENDOR_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_VENDOR_CHANGE

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

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

    var record = await ZFAPPS.get('vendor');
    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_VENDOR_PREVIEW

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

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

    var record = await ZFAPPS.get('vendor');
    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_VENDOR_PRE_SAVE

This event is triggered just before the vendor 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 :
vendor.creation.sidebar
Sample Code :
REQUEST DETAILS
ZFAPPS.extension.init().then(function(App) {
  App.instance.on('ON_VENDOR_PRE_SAVE').then(async function() {

    var record = await ZFAPPS.get('vendor');
    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_VENDOR_PAGE_LOAD

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

Supported Locations :
vendor.creation.sidebar
Sample Code :
REQUEST DETAILS
ZFAPPS.extension.init().then(function(App) {
  App.instance.on('ON_VENDOR_PAGE_LOAD').then(async function() {
    // Set default value for a custom field
    await ZFAPPS.set('vendor.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);
  });
});