Updating the Opportunity and Case totals in the Company's top content

SUGGESTED

Hi,

In regards to: How do I put calculated or derived info in a screen's top content?

We have used the script provided in the link above to display the number of Opportunities and Cases that are currently active within a Company, within the 'top content' section of the screen. However, we've found that this number/calculation does not update straight away if you create a new Opportunity or Case.

If we create a new Case under a company, the number within the top content does not update unless you click on the Company Name and reload the company again. Any ideas for how we can alter the script to make the updates instantaneous?

var oppoRecord = CRM.FindRecord("opportunity","oppo_status='Open' and oppo_primarycompanyid="+CRM.GetContextInfo("company","comp_companyid"));
var caseRecord = CRM.FindRecord("cases","case_status='Open' and case_primarycompanyid="+CRM.GetContextInfo("company","comp_companyid"));

Caption = "<Table border=0><tr><td align=right class="topcaption">";
Caption +=CRM.GetTrans("Tabnames","Open Opportunities");
Caption +=":</td><td class="topheading">";
Caption +="<a href="+CRM.URL(184)+" class="TOPSUBHEADING">"+oppoRecord.RecordCount+"</a>";

Caption +="</td></tr><tr><td align=right class="topcaption">" ;
Caption +=CRM.GetTrans("Tabnames","Open Cases");
Caption +=":</td><td class="topheading">";
Caption +="<a href="+CRM.URL(185)+" class="TOPSUBHEADING">"+caseRecord.RecordCount+"</a>";

Caption +="</td></tr></table>" ;

Thanks all

Hannah