Below is a very simple example of a self service page that allows a case belonging to an authenticated visitor to be edited.

The ASP code is found below.   The code is comment and discussed.

 


<%@CodePage=65001 Language=JavaScript    %>
<!-- #include file ="ewaress.js" -->
<%
CRM = eWare;
var View=0, Edit=1, Save=2, PreDelete=3, PostDelete=4, Clear=6;
var Bottom=0, Left=1, Right=2, Top=3;
var CapDefault=0, CapTop=1, CapLeft=2, CapLeftAligned=3, CapRight=4, CapRightAligned=5, CapLeftAlignedRight=6;
var Button_Default="1", Button_Delete="2", Button_Continue="4";
////////////////////////////////////////////////////
var Head="<HTML><HEAD><LINK REL=\"stylesheet\" HREF=\"eware.css\"><META http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">";
var Body="<BODY>";
var EndBody="</BODY></HTML>";
Response.Write(Head);
Response.Write(Body);
if (CRM.Authenticated)
{
//Grabbing CaseID from QueryString
var strKeyID= "case_caseid";
var Id = new String(Request.Querystring(strKeyID));
var intCaseId = 0;
if (Id.indexOf(",") > 0)
{
   var Idarr = Id.split(",");
   intCaseId = Idarr[0];
}
else if (Id != "")
{
  intCaseId = Id;
}
//Uses Self Service User context to retrieve Person data.
var intRecordId = CRM.VisitorInfo("visi_personid");
var PersonRecord = CRM.FindRecord('person','pers_personid='+intRecordId);
//A very basic check to ensure that authenticated users can only see their own records.
//and Unauthenticated visitors have no access
var CaseRecord = CRM.FindRecord('cases','case_primarypersonid = '+ intRecordId+ ' and case_caseid='+intCaseId);
if (!CaseRecord.eof)
{
//Control and Setting Properties of Entry Blocks
var myBlock = CRM.GetBlock("sscaseentry");
//myBlock.Title = CRM.GetTrans("tabnames","cases");
var entryBlock = myBlock.GetEntry("case_problemnote");
var entryDescription = myBlock.AddEntry("case_description",1,false);
var entrySource = myBlock.AddEntry("case_source",-1,true);
var entryCustomerRef = myBlock.AddEntry("case_customerref",-1,true);
entryCustomerRef.NewLine = false;
 
var strHTML = myBlock.Execute(CaseRecord);
if (CRM.Mode == Save)
{
Response.Redirect("customcases.asp");
}
else
{
Response.Write(strHTML);
}
}
else
{
Response.Write("No Record Found");
}
}
else
{
  Response.Redirect("customlogon.asp");
}
////////////////////
Response.Write(EndBody);
%>
 

 

Grabbing CaseID from QueryString

A hyperlink from a list block in Self Service will typically pass the target records primary key value in the query string. 

Basic Security Check

Because the target record ID is included in the querystring URL a double check has to be made that the person looking for the record is entitled to view the record.  Without a check that includes the authenticated Visitor's ID anyone could go on a data fishing expedition.

Control and Setting Properties of Entry Blocks

This section shows that you can edit the consituent fields (entry blocks) of a screen (EntryGroup) block.  You can remove and add new fields programmatically and you can set properties such as NewLine easily.