Displaying Multiple List Blocks using the ASP COM API

Hints, Tips and Tricks

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

Displaying Multiple List Blocks using the ASP COM API

  • Comments 21
  • Likes

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 <iframe> which calls a page that displays the second list block.

The code for the wrapper page is shown below



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');
with (myBlockContainer)
{
AddBlock(myOppoBlock);
AddBlock(myContentBlock);
}
CRM.AddContent(myBlockContainer.Execute(Arg));
Response.Write(CRM.GetPage());




The Inner page is much simpler. The code includes some client side javascript that makes sure the hyperlinks correctly target the main frame of CRM.


<!-- #include file ="accpaccrm.js"-->

<script>
window.attachEvent("onload",hideButton);
function hideButton()
{
var strSpan="";
var strLink="";
// hide the button
for(i=0;i<document.all.length;i++)
{
if(document.all[i].tagName=='A' )
{

document.all[i].target = "EWARE_MID";

}
}
}
</script>
<%

Response.Write(Head);

var myBlock = CRM.GetBlock('caselist');
var myRecordId = CRM.GetContextInfo('company','comp_companyid');
var Arg = 'case_primarycompanyid='+myRecordId;
Response.Write(myBlock.Execute(Arg));

%>


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.

I have posted an article that gives an example of a rebuild of a company quicklook screen.

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.

Comments
  • Try

    <script>

    window.attachEvent("onload",hideButton);

    function hideButton()

    {

    var strSpan="";

    var strLink="";

    // hide the button

    for(i=0;i<document.all.length;i++)

    {

    if(document.all[i].tagName=='A' && document.all[i].className!='GRIDHEAD')

    {

    document.all[i].target = "EWARE_MID";

    }

    }

    }

    </script>

  • Works perfectly. We have build our own orders table with orderitems and are dispalying this on the same page. Using the IFrame we can now click through all order items when there are more than the standard grid size.

    Sage uses a trick for the standard order and quote screen so you don't have to browse: the grid just keeps getting longer and longer.

    Jeff: nice trick, would that be available in customizations?

  • Rene

    I thought that when the frame for the new order item was closed it refreshed the parent frame.

  • Jeff,

    Thank you.  I used the iframe approach for multiple list blocks to help me display a loading animation while data was retrieved from a remote server.  This helps "compartmentalize" the slow-to-load data.  Once, the iframe is loaded, I call a function to close the animation.  community.sagecrm.com/.../10054.aspx.

    Thanks for the guidance.

  • Can this still be used for 7.3?  I have tried it and it displays fine except when clicking hyperlink in the grid it redirects within the iframe itself and not the whole page.

  • Sorry, solved it, needed to change

    document.all[i].target = "EWARE_MID";

    to

    document.all[i].target = "_parent";