Question

Hide button

Hi! I wanted to hide a process button and I found a code that could work but I am not sure where to put the name of my button.

 

This is the code: 

 

define("ContactSectionV2", [],

    function() {

    return {

        entitySchemaName: "Contact",

        attributes: {

            "ButtonVisible": {

                "dataValueType": Terrasoft.DataValueType.BOOLEAN,

                "type": Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,

                "value": true

            }

        },

        messages: {},

        methods: {

             onCardRendered: function() {

                 this.callParent();

                 this.set("ButtonVisible", false);

             }

        },

        diff: /**SCHEMA_DIFF*/[

            {

                "operation": "insert",

                "parentName": "ActionButtonsContainer",

                "propertyName": "items",

                "name": "MainContactSectionButton",

                "values": {

                    itemType: Terrasoft.ViewItemType.BUTTON,

                    caption: { bindTo: "Resources.Strings.TestButton" },

                    "visible": {bindTo: "ButtonVisible"},

                    "layout": {

                        "column": 1,

                        "row": 6,

                        "colSpan": 1

                    }

                }

            }

        ]/**SCHEMA_DIFF*/

    };

});

 

Thank you!

Like 0

Like

9 comments

Hi,

I don't really understand what you mean by putting the name of the button, but, if you want to hide you need to find it in the diff section of the page where your button is located and add to it a parameter "visible", as shown on your code.

This parameter is bound to a method "ButtonVisible" and in it, you can return true or false based on the needed condition.

Dmytro Vovchenko,

Thank you! You're right. But I have one problem, I can't find my button in diff. It is a run process button. I searched for this type of button in other sections also, but I can't find it there also. I don't know if process buttons are made differently.

In that case, can you please show the button you are talking about?

 

This one: (Run process)

Ghiu Diana Stefania,

With this button you can simply add to diff of the needed page this statement:

			{
				"operation": "merge",
				"name": "ProcessButton",
				"values": {
					"visible": false
				}
			},

Or instead:

"visible": {bindTo: "ButtonVisible"},

Small remark, this button is not your average one, so probably the best way is to bind the visible parameter to a method. In this method return true or false based on your condition.

It still doesn't work

Try opening your record page and refresh it with F5, I bet that the button will disappear. As I said, this button is pretty special. First of all, its realization is buried somewhere in the base page logic and if it is displayed on any section then it will be shown on both section and record pages. When you are opening the record page from the section than the system will remember some aspects from the section page, which includes the values of this button. In that case, try adding the same diff to the section page as well. Also, this button will disappear by itself if you don't have any business-processes attached to the section.

Dmytro Vovchenko,

I made it work to hide it but I need to put a condition also.  If I put it in methods it does nothing. I can only make the button visible or invisible. Do you have any idea?

 

As I said, you need to bind the parameter "visible" to a method and in that method write a condition that will return true or false.

"visible": { bindTo: "isVisible" }

 

isVisible: function() {

             if ( ---- )  

                     return true;

             return false;

}

Note, this must be present on both pages.

If this won't work, then I believe with the current logic of this button it would be impossible to hide it with your conditions (or this task will require a lot of modifications of base logic, and I'm not sure it is worth it)

Show all comments