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?

  • 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.

  • I am doing something very similar.

    I have a custom module "Events" with another custom module "Event Delegates"
    When I add related contacts, leads or Individuals to the "Event"
    I have a logic hook (SQL) that adds those records as "Event Delegates"

    In the event Record view, when I "link existing record" and select and add a new Contact.

    On save I would like the "Event Delegate" subpanel to auto refresh.

    Following Francescas' guidance I have tried creating the following in 
    D:\SymphonyCRMSites\sym_crm_paydashboard\custom\modules\symEV_EventApprovals\clients\base\views\subpanel-list, 

    ({
    extendsFrom: 'SubpanelListView',
    initialize: function(options){
    this._super('initialize', [options]);
    if(this.context.parent) {
    reloadLinks = ['subpanel-for-symev_events-symev_events_symev_eventapprovals'];
    this.context.parent.set('skipFetch', false);
    // reload the listed subpanels
    this.context.parent.trigger('subpanel:reload', {links: reloadLinks});
    }
    }
    }
    )

    Any help or suggestions greatly appreciated

    Greg

  • The link name is not your subpanel name, it's the name of the relationship that the subpanel gets it data from.

    In my example the relationship between WContracts and WProducts.

    FrancescaS

  • Hi I had another go, using the relationship Name.....
    Did a QRR and it didn't seem to work..

    Just to restate, I am hoping the code below would cause a subpanel to refresh after I add a record to another subpanel on the same module. -- That action causes a SQL logic hook to fire and put a new record in the first subpanel, but it would be nice to get the screen to update to show this without clicking re "reload" button.

    Current code in custom\modules\symEV_EventApprovals\clients\base\views\subpanel-list\subpanel-list.js


    ({
    extendsFrom: 'SubpanelListView',
    initialize: function(options){
    this._super('initialize', [options]);
    if(this.context.parent) {
    reloadLinks = ['symev_events_symev_eventapprovals'];
    this.context.parent.set('skipFetch', false);
    // reload the listed subpanels
    this.context.parent.trigger('subpanel:reload', {links: reloadLinks});
    }
    }
    }
    )

  • Hi Greg,

    your code is missing the listener for the render event (this.on('render',...). Try this:

    ({
        extendsFrom: 'SubpanelListView',
        initialize: function(options){
            this._super('initialize', [options]);
            this.on('render', function() {
                if(this.context.parent) {
                    reloadLinks = ['symev_events_symev_eventapprovals'];
                    this.context.parent.set('skipFetch', false);
                    // reload the listed subpanels
                    this.context.parent.trigger('subpanel:reload', {links: reloadLinks});
                }
            }, this);
        }
    })
  • Hi Greg Mackey, please let us know if Claus' suggestion fixed your issue. Thanks! Emma

  • Hi Claus, do you know if your solution would work for CE? I tried but it didn't refresh the sub-panel. if not, do you have something else to suggest?

    Thank you