Resizing and controlling tables (lists) displayed using the Self Service COM API

2 minute read time.

A customer had a question on how they could resize a table to fit correctly in their web page.

Below is an image that shows a simple page created by the Self Service API.

The code below shows how the display of List Pages can be controlled in Self Service.

This covers everything from the actual data that is fetched, the number of rows displayed on the page and the width of the block within the page.

[code language="javascript"]



<%
/////////////////////////////////////////////////////////
//Filename: testpage.asp
//Description: Demo how the display of List Pages can be controlled in Self Service.
//Date: 2nd October 2015.Date on which the page is completed.
//Author: Jeff Richards */
//Version tested under: Sage CRM XXX
//////////////////////////////////////////////////
//set up alternate object name
CRM = eWare;
//mode constants
var View=0, Edit=1, Save=2, PreDelete=3, PostDelete=4, Clear=6;
//button position constants
var Bottom=0, Left=1, Right=2, Top=3;
//caption location constants
var CapDefault=0, CapTop=1, CapLeft=2, CapLeftAligned=3, CapRight=4, CapRightAligned=5, CapLeftAlignedRight=6;
//default button constants
var Button_Default="1", Button_Delete="2", Button_Continue="4";
////////////////////////////////////////////////////
var Head="";
var Body="";
var EndBody="";

Response.Write(Head);
Response.Write(Body);

///////////////////
/// Main Code
///////////////////

if (CRM.Authenticated) {

//Get VisitorInfo

//Uses Self Service User context to retrieve Person data.

var intRecordId = CRM.VisitorInfo("visi_personid");
var PersonRecord = CRM.FindRecord('person', 'pers_personid=' + intRecordId);

//The list is usually defined in Meta Data. You will need to be able to check the administration screens to know what lists are available.

var myBlock = CRM.GetBlock("SelfServerSolutionsList");
//You can then control the properties of the list to control the way in which the list is displayed
myBlock.PadBottom = true;
myBlock.RowsPerScreen = 20;
myBlock.Width = "100%";

//You can build the list with out reference to meta data.
//var myBlock = CRM.GetBlock("list");
//with (myBlock)
//{
//Only use the myBlock.ViewName property with a list block created dynamcially.
//ViewName = "vReportSolutions";
//or you can define your own sql
//SelectSQL = "select * from table or view";
//}

//The argument is the where clause that limits the data returned to the Visitor's context.
//var Arg = "fieldName="+intRecordId;
//In the case of solutions these are not directly linked to a visitor.
//Usually you would limit the display of solutions to those that we ready for publication.

var Arg = "soln_status='Published'";

//The Whereclause is then passed to the block to limit the rows returned.
Response.Write(myBlock.Execute(Arg));
}
else {
eWareLogin();
}

////////////////////

Response.Write(EndBody);

%>
[/code]