Creating an View/Edit Screen based on a View using the COM ASP API

Less than one minute read time.

Below is a screen shot of a compound screen that populates the fields on the screen from data retrieved from a view.

This page has been built using an ASP page.

It has used the method CRM.FindRecord().

Syntax is

CRM.FindRecord('Entity,vViewName',ArgString);

This is a good way of quickly displaying information from the view. But it can not be used for updating and inserting. In the code below a check is made only to use the fields from the person table (derived from the view) in View mode.

<!-- #include file ="sagecrm.js"-->
<%
var intRecordId = CRM.GetContextInfo("company","comp_companyid");
var myRecord = CRM.FindRecord('Company,vEntityCompany','comp_companyid='+intRecordId);
 
var CompanyBlock = CRM.GetBlock("companyboxlong");
CompanyBlock.Title = CRM.GetTrans("tabnames","company");
CompanyBlock.ArgObj = myRecord;
 
var PersonBlock = CRM.GetBlock("personboxshort");
PersonBlock.Title = CRM.GetTrans("tabnames","contact");
PersonBlock.ArgObj = myRecord;
 
var myBlockContainer = CRM.GetBlock("Container");
with (myBlockContainer)
{
AddBlock(CompanyBlock);
 
//only display person data when in View mode
if (CRM.Mode!=Edit)
{
AddBlock(PersonBlock);
}
 
}

CRM.AddContent(myBlockContainer.Execute());
Response.Write(CRM.GetPage());
%>