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

Hints, Tips and Tricks

Technical Hints Tips and Tricks that cover customization and development using Sage CRM. API usage and coding are covered.

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

  • Comments 3
  • Likes
 Here you can see it is possible to put calculated or derived information into the topcontent. This question actually came up the last time I was here in Germany, but I suppose it is a common requirement.

The example I am going to use is one that requires that the number of 'In Progress' cases and opportunities that are linked to the company should be displayed at the top of the screen. The other requirements are that only the total of the records that the user has a right to see should be displayed and that when the total is clicked it should open the list page for either the opportunities or the cases.
The way to put anything into a screens topcontent is to make use of 3 things. First a new "dummy" field that we no will not hold data and secondly the topcontent box and last the onCreate script of the dummy field when it is added to the topcontent box.
To add the dummy field, go to
Administration -> Customization -> Company
Within the fields tab, click 'new' and add a new field. I typically call mine just comp_dummy and have it as a text field with a length of 1 and set to be readOnly.
When the field is created. Click on the screens tab and then edit the companytopcontent screen.
Add the new dummy field into the screen.
Add the following code into the Createscript box:

[code language="javascript"]
var oppoRecord = CRM.FindRecord("opportunity","oppo_status='In Progress' and oppo_primarycompanyid="+CRM.GetContextInfo("company","comp_companyid"));
var caseRecord = CRM.FindRecord("cases","case_status='In Progress' and case_primarycompanyid="+CRM.GetContextInfo("company","comp_companyid"));
Caption = "<Table border=0><tr><td align=right class=topcaption>";
Caption +=CRM.GetTrans("Tabnames","Opportunities");
Caption +=":</td><td class=topheading>";
Caption +="<a href="+CRM.URL(184)+" target=EWARE_MID CLASS=TOPSUBHEADING>"+oppoRecord.RecordCount+"</a>";
Caption +="</td></tr><tr><td align=right class=topcaption>" ;
Caption +=CRM.GetTrans("Tabnames","Cases");
Caption +=":</td><td class=topheading>";
Caption +="<a href="+CRM.URL(185)+" target=EWARE_MID CLASS=TOPSUBHEADING>"+caseRecord.RecordCount+"</a>";
Caption +="</td></tr></table>" ;
  • Instead of using the field Caption property use the CRM.AddContent method. See my recent blog on using the CRM.AddContent method.

  • hi, how do you make computations and show it in the top screen?

  • This article does discuss how you can display calculated values in the TopContent.