Self Service Workarounds

2 minute read time.
If you have been working with Self Service then you know that certain field entrytypes are not rendered in the same way in Self Service screens as they are in the main application extension ASP pages.

These oddly behaving fields or entrytypes include Date, DateTime and Search Select Advanced fields. Typically the display of the information is not the problem but rather the update of the field. "The search select doesn't work or the popup calendar doesn't appear".

The features that are available in application extension ASP pages are just not there for Self Service because of the different architecture and authenication used in the pages.

Below is some example code that shows how in a Self Service Page we can workaround the limitations and force in the behaviour we want.

Note: This is a very simple example that only provides a drop down box instead of a Search Select Advanced but it does illustrate how we can change the behaviour of a field in edit mode.
Note: If you are working with Self Service pages the object that the ewaress.js include file instantiates is the "eWare" object. The code snippets and resources provided alias the object to be called "CRM". Using an object name of "CRM" rather than "eWare" is the standard for coding in the COM API in Sage CRM. But for the sake of backwards compatibility and to avoid confusion the code below still refers to "eWare" not "CRM".


if (eWare.Mode==View)
{
eWare.Mode =Edit;
}

var leadcustomscreenBlock = CRM.GetBlock("leadcustomscreen");
var leadcompanyscreenBlock = CRM.GetBlock("leadcompanyscreen");
var leadpersonscreenBlock = eWare.GetBlock("leadpersonscreen");
var LeadAddressScreenBlock = eWare.GetBlock("LeadAddressScreen");

if (eWare.Mode==Edit)
{
////////////////////Sort out WaveItem lookup //////////////////////////
var customAppDataSelectionEntryBlock = leadcustomscreenBlock.GetEntry("lead_waveitemid");
var CustomField = "";
var WaveItemsRecords = eWare.FindRecord("waveitems","wait_deleted is null");
WaveItemsRecords.OrderBy = "wait_name";
while (!WaveItemsRecords.eof)
{
CustomField+=""+WaveItemsRecords.wait_name+"";
WaveItemsRecords.NextRecord();
}
CustomField +="";

with(customAppDataSelectionEntryBlock)
{
ReadOnly = true;
NewLine = false;
Caption = eWare.GetTrans("ColNames","wait_Name")+":
"+CustomField;
}
///////////////////////////////////////////////////////////////////////

}

var myRecord = eWare.CreateRecord("lead");

var myBlockContainer = eWare.GetBlock("Container");
with (myBlockContainer)
{
AddBlock(leadcustomscreenBlock);
AddBlock(leadcompanyscreenBlock);
AddBlock(leadpersonscreenBlock);
AddBlock(LeadAddressScreenBlock);
}
Response.Write(myBlockContainer.Execute(myRecord));

if (eWare.Mode==Save)
{
Response.Write("Record Entered");
}


The change that I have made here for a Search Select Advanced field can be carried out for a Date field. There are plenty of example scripts freely available that can be used to enhance the Date field behaviour in Self Service pages.
  • Fields of type "Search Select Advanced" can not work in Self Service pages like they do in the main user interface. This is because they use the concept of the user session to carry out the look ups into Sage CRM. BUT in Self Service there is no user session. Self Service uses a completely different authentication mechanism for web site visitors. By design SSAs can't work in Self Service. This requires you to either use a work around like this article decribes OR design your self service site differently. For example, rather than start with the child and look up to the parent instead start with the parent and create the child.