in Search

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?

This article has been updated (20/11/2008) and brought into line with Sage CRM 6.2 coding conventions.
 
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:

 
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>" ;

Comments

 

Hints, Tips and Tricks said:

This article has come about because of a question from a partner working on implementing Sage CRM where

December 4, 2008 5:50
 

Hints, Tips and Tricks said:

When you edit or add a new address for a person in Sage CRM you are invited to specify whether the address

April 14, 2009 10:14
 

Hints, Tips and Tricks said:

A screen like the company summary screen has a very particular structure because it is partially defined

May 22, 2009 7:59
 

JackAllan said:

Instead of using the field Caption property use the CRM.AddContent method. See my recent blog on using the CRM.AddContent method.

October 5, 2009 8:18

About Jeff Richards

As the Head of Training Program Development for Sage Technologies, I am responsible for providing the technical education for the Sage CRM Development Partner community. I write and present regularly on Sage CRM development techniques, hints and tips. I also provide education and training for the staff of local Sage companies in new technical features and act as a resource for Sage trainers as they develop their training courses. I have been working with Sage CRM since early 2001 (version 2.85) and I have a thorough understanding of the issues faced by partners carrying out implementations. I have been working within the Software Industry since 1993. I have a strong background in Business Rules and Workflow.

News

To help you find information quickly, use the tag cloud on the righthand side of the page. Every article and file posted is marked with one or more tags. The tags are mainly single words and are listed alphabetically. The more frequently a tag has been used to mark an article the bigger it will appear in the cloud. The tags are hyperlinks that lead to a collection of items that are associated with a tag. To find an article that discusses creating XML feeds using ASP pages, click on ASP, then on the next page click on XML.

This Blog

Syndication

sagecrm.com Articles