How to disable sub panel row actions conditionally based on parent model?

What is the best practice to conditionally disable edit/add/ un-link actions on sub panel where parent module is assigned to a status.
For example:

If parent status is 'Closed' -> Sub panel records should not be altered.

Message was edited by: Alex Nassi

  • This code does not disable the "+" Create button but it allows you to display a message if certain conditions are true.

    In this case, the code gets triggered when the user clicks on Create button for Revenue Line Items subpanel.

     

    custom/modules/RevenueLineItems/clients/base/views/panel-top/panel-top.js

    ({
       extendsFrom: "PanelTopView",

       createRelatedClicked: function(event) {
          var self = this;
          var oppStatus = self.context.attributes.parentModel.attributes.status_oppty_c;

          app.alert.dismiss('opp-rli-create');

          if (oppStatus == 'In Progress'){
             this._super("createRelatedClicked", [event]); //open create drawer
          }else{
             app.alert.show('disableCreate', {
                level: 'warning',
                messages: 'your message here',
                autoClose: true,
                autoCloseDelay : 10000,

             });
          }
       }
    })

    Hope this helps.

    Regards, 

    Angel M.