Above is a screen shot that shows a default opportunity summary page. At the top of the page is the frame that contains the TopContent information. Sometimes this is called the context information. In this screen the TopContent brings in data from the Opportunity, the Company and the Person entities. The Phone and Email information actually comes from the Company table.
Control of the TopContent typically comes in two forms. Either we will want to add more information into the TopContent area or we will want to remove data from the TopContent frame.
I will look at both in turn. Adding Data to the TopContent area.
Each default main entity in CRM has an extra screen block defined in Meta Data to allow us to add additional content to the screen.
For the Opportunity Entity this is called OppoTopContent.
You can find this screen under the Screen tab within the Administration -> Customization -> Opportunity area.
Default TopContent Screens Cases
- CaseTopContent Communication
- CommunicationTopContent* Company
- CompanyTopContent Lead
- LeadTopContent Opportunity
- OppoTopContent Orders
- OrdersTopContent++ Person
- PersTopContent Quotes
- QuotesTopContent++ *
Please note that this entities behaviour is different and actually the screen fields are not added to the display. ++
Sage CRM 6.1 onwards
Although it is possible to add additional fields to the TopContent area consideration has to be given to the space available and what effect this is going to have on the appearance and readability of the screen.
In the example below I have added two fields into the OppoTopContent screen.
Here we can see that I have used the Create script to change the properties of the field being included. This concept is very important and I'll come back to this later in the article when discussing the display of derived or extra information.
The fields added to the TopContent are then displayed as we can see.
So we have seen that we can include additional information into the TopContent area of the screen for default entities. We can actually do this for Custom Entities too.
In the image above we can see that I have added TopContent information into the screen for the new Project entity.
The screen I used is called ProjectTopContent. You can see how it was created in the image above.
The custom project entity was created as a new main or primary entity. To call the TopContent screen in the ASP pages I used the method eWare.GetCustomEntityTopFrame("Project");
This method assumes that for the project entity there is a screen called ProjectTopContent. This means that if you create a new main entity (e.g. XXXXX
) you should create a screen called XXXXX
TopContent. Displaying Derived Information in the TopContent area.
We saw with the default entities that we can add additional fields from that entity into the TopContent area. But that is a limitation. We can add Company fields to our CompanyTopContent screen, we can add Opportunity fields into our OppoTopContent screen. But what if we wanted to add other data into the TopContent? For example how can we add a count of the total number of "In Progress" cases and opportunities into the CompanyTopContent screen? Other Limitations of the TopContent area.
There are a few important limitations to be aware of when working with the TopContent screens. The first is that these screens are only ever displayed in View mode. Therefore no onChange events can be used. And since nothing is going to be submitted so there are no Validation checks either.
One big thing to note is that the custom content box of the screen is not used. We can not put script into the custom content box and have it passed to the browser.
Also the TopContent screen is not rendered within html <FORM> tags and the data items displayed are not wrapped in the <span> tags with ID values that normally allow fields in the main display area to be easily addressed in clientside code. Changing the Default TopContent Data Displayed (Sage CRM v7.1sp2 and earlier).
Note: The method described below is applicable only to Sage CRM v7.1sp2 and earlier. For Sage CRM v7.2 onwards please reference the new Client Side API.
The limitations discussed above will influence how we can change the default information in the TopContent area of the screen.
We can't use the same techniques that we would in the main part of the page. But the TopContent is still HTML and it can still be referenced in code that exists elsewhere in the page. So in our example of the OpportunitySummary page we could place code in the Custom Content of the OpportunityDetailBox and have this code change the TopContent area.
//firefox way of binding an event
window.addEventListener("load", googleCompany, false)
//IE exclusive method for binding an event
var objTopContent = parent.frames.document.activeElement;
var strTopContentHTML = objTopContent.innerHTML
//change the strTopContentHTML is any way you want. For example
strTopContentHTML = CurrentUser.user_lastname;
//then write the frame contents back out
parent.frames.WriteToFrame(5,"TOPBODY VLINK=NAVY LINK=NAVY",strTopContentHTML);
The function above will read the existing HTML in the TopContent frame. It allows us to change the HTML in anyway that we want. So we could parse this HTML and replace or remove information that needs to be changed. The function then rewrites the altered HTML back into the TopContent frame.
Once you have got the HTML within a string it simply becomes a question of string manipulation. Here we can use any JScript string handling technique we want whether it is methods such as substr() the use of regular expressions.
Note: This "changeTopContent()" function uses another function called WriteToFrame() that is a Sage CRM created function. This function exists in the left menu frame.
So the example code above shows that we do have total control of what goes into the TopContent area of any entity screen.