How do I disable a button or change the function behind it?

Hi community,

I am looking for 2 possibilities:

1. How can I disable a copy button in the list of opportunities?

2. How can I change the functionality behind the button?

Thanks

Like 0

Like

6 comments

Just override method at OpportunitySectionV2:

copyRecord: function(editPageUId) {
    this.showInformationDialog("Not allowed");
}

 

Hello Martin,



Dmitry is right, you should simply override the desired method in replacing client module.

Please note, that if you want to save base functionality as well as add something new to it don`t forget to call callParent method. It triggers base method logic so you will be confident that base logic will work just as planned.



For example how it will look like with copyRecord method

copyRecord: function(editPageUId) {
    this.callParent(arguments);
    // custom logic
}

Best regards,
Alex

Hi Alex,

Thanks for the answer.

And is there the possibility to hide the button?

 

Best regards

Martin

 

Zurkowski Martin,

Hello,



You can simply bind it`s visible property to some boolean attribute or function.

If you want to hide not a new button but existing one, you should use "merge" operation. 

Also please follow the link to find information about diff array:

https://academy.bpmonline.com/documents/technic-sdk/7-13/diff-array



Here is an example:{

                "operation": "insert",

                "name": "12345Button",

                "values": {

                    "itemType": 5,

                    "caption": "12345",

                    "visible": {bindTo: "Show12345Button"},

                    "layout": {

                        "column": 1,

                        "row": 6,

                        "colSpan": 2,

                        "rowSpan": 1

                    }

                },

                "parentName": "LeftContainer",

                "propertyName": "items",

                "index": 9

            }

Best regards,

Alex

 

Hi Dmitry, hi Alex,

thank you both for the help.

At first I could not find out how the copy-button is called and where I find it in the opportunity-grid. At the end its called "Resources.Strings.CopyRecordGridRowButtonCaption"

It works both.

Thank you!

Hi all,

Let me share a way to actually hide the button (not just overriding its method to show an alert).

You can override onRender() method of your Section client schema, and in this method you can remove the Copy button like this:

onRender() {
    this.callParent(arguments);
 
    const dataGrid = this.getCurrentGrid();
    const rowButtons = dataGrid.activeRowActions;
    let idxToDelete;
    for (let idx = 0; idx < rowButtons.length; ++idx) {
        const btnObj = rowButtons[idx];
        if (btnObj.tag === "copy") {
            idxToDelete = idx;
        }
    }
 
    rowButtons.splice(idxToDelete, 1);
},

Worth to mention that the solution with diff in schema won't work in this particular case: activeRowActions is just an array, not a key-valued object, so the "merge" operation would be meaningless.

Show all comments