How do I refresh a subpanel when a record is added to a different subpanel?

On a case record I create a meeting using the create button on the subpanel. When the new meeting is saved an advanced workflow process creates a new task related to the case record. 

I want the tasks subpanel to refresh when the meeting is added to show the new task when the drawer closes and the user is returned to the case record view. How can this be done?

Parents
  • Here is a possible solution.

    I have a module called WContracts with two subpanels: Products and Details.

    When a Product is added, deleted or changed there are several logic hooks that add/delete/modify entries in the Details module. And I want the Details subpanel to refresh immediately without reloading the whole page.

    When a Product is deleted I also want to refresh the Parent (Contract) to update some calculated fields.

    in my WProducts module's SubpanelListView

    custom/modules/wcont_WProducts/clients/base/views/subpanel-list/subpanel-list.js

    ({
      extendsFrom: 'SubpanelListView',
      initialize: function(options){
        this._super('initialize', [options]);
        this.on('render', this.refreshDetails, this);

        if(this.layout){
          this.layout.on('list:record:deleted', function() {
            this.refreshCollection();
            this.refreshParent();
          }, this);
        }
      },
      refreshParent: function(){
        var parentmodel = this.context.parent.get('model');
        parentmodel.fetch();
      },
      refreshDetails: function() {
        var parentContract = this.context.parent.get('model'),
            detailsLink='<the name of the link between the parent and the details>',
            contractDetailsCollection = parentContract.getRelatedCollection(detailsLink);
        contractDetailsCollection.fetch({relate:true});
      },
      _dispose: function() {
        this._super('_dispose');
      },
    })
      

    If you want to refresh multiple subpanels you can do so in one go using the link names that relate each of the subpanel modules to the parent

            if(this.context.parent) {
              reloadLinks = ['<linkName1>', '<linkName2>'];
              this.context.parent.set('skipFetch', false);
              // reload the listed subpanels
              this.context.parent.trigger('subpanel:reload', {links: reloadLinks});
            }

    HTH,

    FrancescaS

  • Hi Francesca,

    That works perfectly! Thanks very much for your help.

Reply Children