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.
<%@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)
{
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.