Creating and Controlling an Insert Page in Self Service

Less than one minute read time.

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 below.




" HREF=\"eware.css\">";
var Body="";
var EndBody="";
 
Response.Write(Head);
Response.Write(Body);
 
if (CRM.Authenticated)
{
 
if (CRM.Mode == View)
{
CRM.Mode = Edit;
}
//Uses Self Service User context to retrieve Person data.
var intRecordId = CRM.VisitorInfo("visi_personid");
var PersonRecord = CRM.FindRecord('person','pers_personid='+intRecordId);
var CaseRecord = CRM.CreateRecord("cases");

//Setting field values and workflow state
CaseRecord.case_primarypersonid= intRecordId;
CaseRecord.case_primarycompanyid= PersonRecord.pers_companyid;
CaseRecord.case_status= "In Progress";
CaseRecord.SetWorkflowInfo("Case Workflow", "Logged");
 
//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.Redirect("customlogon.asp");
}
////////////////////
Response.Write(EndBody);
%>

Setting field values and workflow state

This section demonstrates how the initial workflow state of a newly created record can be set. Also non displayed field values can be set here.

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.