Displaying Multiple List Blocks using the ASP COM API

2 minute read time.

We have seen in other posts that it is perfectly possible to create ASP pages that contain multiple blocks. These have been search pages or entry pages that have drawn their blocks from either the same or different entities.

What we have not discussed so far is the display of multiple list blocks within the same page. Consider the idea of creating a page in the context of a company that brings together the cases and opportunities for that company.

The effect would be like the Quicklook screen only what we would like to be able to do rather than have only 4 rows displayed have the 10 or so rows that is set by our preferences and it should allow us to navigate to subsequent pages of information.

There is a problem with this. The list block in CRM returns a standard set of HTML to control the next, previous and other navigation within the records. So if more that one list block is rendered there will be a conflict of what the different elements in the page are called and what the different hyperlink buttons are trying to address.



But as you can see from the above diagram there must be away to allow multiple list blocks to be displayed and to navigate correctly.

What has been down is to create a page that contains one list block and an which calls a page that displays the second list block.

The code for the wrapper page is shown below


<!-- #include file ="sagecrm.js"-->
<!-- Typical ASP Page Structure (Try - Catch) -->
<%
var myOppoBlock = CRM.GetBlock('opportunitylist');
var myRecordId = CRM.GetContextInfo('company','comp_companyid');
var Arg = 'oppo_primarycompanyid='+myRecordId;
var myContentBlock = CRM.GetBlock('Content');
myContentBlock.contents = '<IFRAME FRAMEBORDER="0" MARGINHEIGHT="0" MARGINWIDTH="0" SCROLLING="NO" NORESIZE WIDTH=100% HEIGHT=400 src="'+CRM.URL("companycaselist.asp")+'"></IFrame>';
var myBlockContainer = CRM.GetBlock('Container');
myBlockContainer.DisplayButton(Button_Default) = false;
with (myBlockContainer)
{
AddBlock(myOppoBlock);
AddBlock(myContentBlock);
}
CRM.AddContent(myBlockContainer.Execute(Arg));
Response.Write(CRM.GetPage());

%>



The Inner page is a little different. The code includes some client side JavaScript that makes sure the hyperlinks correctly target the main frame of CRM.



Note: The CRM.GetPage() method has not been used to render the page as we do not want to include the Tab bar and notifications in the inner frame.

This method is something of a cheat and there are still problems with this approach. For example thought must be made as to the target of the hyperlinks. Hyperlinks on the list block contained in the inner frame will by default target the inner frame and not the wrapper frame. This has now been addressed in the above code.

Another approach for the inner frame that can be used, is to create a new list definition in meta data and to include in the custom content of that list block the script that changes the hyperlinks in the column to target the wrapper parental frame.

But as you will see from the sample of code included in the post linked to below, the .NET API will make tasks like the rebuilding of the company quicklook easier because of the lower level control the API provides over the blocks.