AnsweredAssumed Answered

Extending preview-button

Question asked by Rodrigo Morchio on May 28, 2018

Hi everyone,


I'm currently working in a Sugar PRO instance, trying to customize the preview button of certain module.


Let's say I'm on an Account record view and I want to customize the behavior of the preview button for the Opportunities module.

Opportunities subpanel in Accounts record view


Initially I just want to log something in the console when the button is clicked without removing its normal functionality. It should be something like this inside the initialize function:

console.log("I'm extending preview-button");


According to what I found, the preview button is defined in /clients/base/fields/preview-button, with the files:

  • preview-button.js (extends 'RowactionField' and only has the function initialize)
  • detail.hbs
  • list.hbs
  • small.hbs


So what I should do is extend the file preview-button.js for a certain module. I'm not sure whether it should be for the Accounts module or the Opportunities module, so I did the following for both:

  1. Created custom/modules/<module>/clients/base/fields/preview-button
  2. Copied preview-button.js inside that folder and modified its content to:
    extendsFrom: 'PreviewButtonField',

    isBwcEnabled: undefined,

    tooltip: undefined,

    initialize: function(options) {
        console.log("I'm extending preview-button");
        this._super('initialize', [options]);


Then I run a QR&R and when I click the preview button nothing is logged in the browser console, it just stays with its normal behavior. This is not working for the list view either.


I should be missing something here but I can't see what it is. I would appreciate any help or advice provided.