How to Hide the Button on the Screen, On Custom_FormPage

Hello Community,

 

I have created a custom page as shown below and added a button to the top bar.

 

When adding a new record, I want to hide the 'Add to Timesheet' button.

 

I want to learn, how to define the method and Method Calling in UsrTasks_FormPage in schema Designer.

UsrTasks_FormPage  Schema:

 

define("UsrTasks_FormPage", /**SCHEMA_DEPS*/[]/**SCHEMA_DEPS*/, function/**SCHEMA_ARGS*/()/**SCHEMA_ARGS*/ {
 
    var IsVisible = function() {
        //Logic is to Hide the Button on New Reacord Creation
    };
    return {
     viewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/[
                   {
                "operation": "insert",
                "name": "AddToTimesheet",
                "values": {
                    "type": "crt.Button",
                    "caption": "#ResourceString(AddToTimesheet_caption)#",
                    "color": "primary",
                    "disabled": false,
                    "size": "large",
                    "iconPosition": "only-text",
                    "visible": { bindTo:  "IsVisible" },
                    "clicked": {
                        "request": "crt.CreateRecordRequest",
                        "params": {
                            "entityName": "UsrTimesheet",
                            "defaultValues": [
                                {
                                    "attributeName": "UsrProject",
                                    "value": "$PDS_UsrProject_yuj01i4"
                                },
                                {
                                    "attributeName": "UsrTask",
                                    "value": "$Id"
                                }
                            ]
                        }
                    },
                    "clickMode": "default"
                },
                "parentName": "ActionButtonsContainer",
                "propertyName": "items",
                "index": 0
            }
     ]/**SCHEMA_VIEW_CONFIG_DIFF*/,
        viewModelConfigDiff: /**SCHEMA_VIEW_MODEL_CONFIG_DIFF*/[]/**SCHEMA_VIEW_MODEL_CONFIG_DIFF*/,
        modelConfigDiff: /**SCHEMA_MODEL_CONFIG_DIFF*/[]/**SCHEMA_MODEL_CONFIG_DIFF*/,
        handlers: /**SCHEMA_HANDLERS*/[]/**SCHEMA_HANDLERS*/,
        converters: /**SCHEMA_CONVERTERS*/{}/**SCHEMA_CONVERTERS*/,
        validators: /**SCHEMA_VALIDATORS*/{}/**SCHEMA_VALIDATORS*/
    };
});

 

 

Regards,

Ajay K

Like 0

Like

4 comments
Best reply

If you're wanting to wire up code to run when the button in clicked, see this article: https://customerfx.com/article/adding-a-button-to-execute-custom-code-on-a-creatio-freedom-ui-page/

As for the visible property, using {bindTo: "something"} doesn't work for Freedom UI pages (that is for classic). Instead you'd add an attribute and bind it using "$AttributeName", then set that attribute elsewhere like in the model init request. 

Using attributes: https://customerfx.com/article/using-custom-attributes-on-a-creatio-freedom-ui-page/

Using the model init handler: https://customerfx.com/article/waiting-for-model-to-be-ready-and-loaded-in-the-crt-handleviewmodelinitrequest-on-creatio-freedom-ui-pages/

This article shows how to make something visible or not based on if the user is a member of a role: https://customerfx.com/article/showing-or-hiding-a-field-if-the-current…

Ryan

You can choose the visibility to "visible": { bindTo:  "IsVisible" } and add the conditions if needed:

isVisible: function() {
             if ( ---- )  
                     return true;
             return false;
}
 
OR
 
showButton: function() {
			this.callParent();
			this.set("isVisible", false);
			},

Best regards, Anhelina!

Anhelina,

Could you please clarify how to define the function in the schema?  

Is there any reference how to define the Functions in "ClientUnitSchemaDesigner". 

If you're wanting to wire up code to run when the button in clicked, see this article: https://customerfx.com/article/adding-a-button-to-execute-custom-code-on-a-creatio-freedom-ui-page/

As for the visible property, using {bindTo: "something"} doesn't work for Freedom UI pages (that is for classic). Instead you'd add an attribute and bind it using "$AttributeName", then set that attribute elsewhere like in the model init request. 

Using attributes: https://customerfx.com/article/using-custom-attributes-on-a-creatio-freedom-ui-page/

Using the model init handler: https://customerfx.com/article/waiting-for-model-to-be-ready-and-loaded-in-the-crt-handleviewmodelinitrequest-on-creatio-freedom-ui-pages/

This article shows how to make something visible or not based on if the user is a member of a role: https://customerfx.com/article/showing-or-hiding-a-field-if-the-current…

Ryan

Ajay,

Ryan is right. Suggested method works for ClassicUI but doesn't work with Freedom UI. The way to use visible property has changed. You can check the instructions from the Academy "Hide the feature on a page behind access permissions"

Show all comments