Sage CRM 2017 R1: Using a Website gadget to include a custom script page in an Interactive Dashboard

Sage CRM has a wide range of different gadget types that can be included in the Interactive Dashboard.

Below you can see that I have created a custom Dashboard which includes List Gadgets, Chart Gadgets and a Record Summary Gadget. There is also a custom gadget in the top left of the dashboard.

This has been created by using a Website Gadget that references an ASP page running with in Sage CRM.

Dashboard -> Create New Web Site Gadget

In the Web Address field I added


Note 1: #crm_server# is a special code that the Dashboard understands to refer to the current server.

Note 2: This is a static URL with no session or state information. This means that we can not directly call the main CRM ASP API which depends on the Session and State information being included in the URL.

My file gadget1.asp page contained the following code:

function GetKeyValue(querystringname)
var strPathFull = String(Request.ServerVariables("HTTP_REFERER"));
var arrayPath = strPathFull.split("?");
var strPath = arrayPath[1];
var arrayKeys = strPath.split(" &");
for (var i=0;i
var arrayValue = arrayKeys[i].split("=");
if (arrayValue[0].toLowerCase()== querystringname.toLowerCase())
return arrayValue[1];
return "";
Response.Redirect("http://localhost/CRM2017/CustomPages/gadgetCustomSummary.asp?SID="+GetKeyValue("SID")+" &J=gadgetCustomSummary.asp &T=User &PopupWin=Y")

Note 1: The HTTP_REFERER obtained using Request.ServerVariables("HTTP_REFERER") provides access to the originally calling URL of the Interactive Dashboard which includes Session and some state information. The SIS (Session ID) is essential for security.

Note 2: This page carries out a redirect to the target page. Response.Redirect("http://[servername]/[instancename]/CustomPages/[targetpage]asp?SID="+GetKeyValue("SID")+" &J=[targetpage].asp &T=User &PopupWin=Y")

Note 3: The &PopupWin=Y is needed otherwise it will draw all the menus in the new gadget.


As an example of a custom gadget this page displays the count of current 'In Progress' or 'Pending' Cases, Opportunities and Communications for the current user.

This particular gadget uses a simple HTTP meta tags to cause the page to refresh every 2 minutes.

The code can be found below.

//Get Context Info

var intRecordId = CRM.GetContextInfo("user","user_userid");
var oppoRecord = CRM.FindRecord("opportunity", "oppo_status='In Progress' and oppo_assigneduserid=" + intRecordId);
var caseRecord = CRM.FindRecord("cases", "case_status='In Progress' and case_assigneduserid=" + intRecordId);
var commRecord = CRM.FindRecord("Communication, vCommunicationAll", "comm_status='Pending' and cmli_comm_userid=" + intRecordId);

var caseContent = CRM.GetBlock("content");
caseContent.contents = "

caseContent.contents += "";
" + caseRecord.RecordCount+"

caseContent.contents += "";

caseContent.contents += "";
caseContent.Width = "100px";
caseContent.Height = "100px";

var oppoContent = CRM.GetBlock("content");
oppoContent.contents = "

oppoContent.contents += "";
" + oppoRecord.RecordCount+"

oppoContent.contents += "";

oppoContent.contents += "";
oppoContent.Width = "100px";
oppoContent.Height = "100px";
oppoContent.NewLine = false;

var commContent = CRM.GetBlock("content");
commContent.contents = "

commContent.contents += "";
" + commRecord.RecordCount+"

commContent.contents += "";

commContent.contents += "";
commContent.Width = "100px";
commContent.Height = "100px";
commContent.NewLine = true;

var myBlockContainer = CRM.GetBlock("Container");
with (myBlockContainer)
DisplayButton(Button_Default) = false;