The code below demonstrates how a page like the Preferences screen can be rebuilt in Sage CRM. This particular screen may be needed to be replaced if the business wishes to offer users only a limited set of preferences that maybe controlled. In the default system the system administrator can either let the user control all their preferences or non of them.
You can learn more about building screens without reference to meta data here:
- Building selection lists in ASP pages without reference to Metadata
- Building Lists without reference to Metadata in the ASP COM API
var intRecordId = CRM.GetContextInfo("user","user_userid");
var myRecord = CRM.FindRecord("usersettings","uset_key='NSet_LoginTo' and uset_userid="+intRecordId);
var myBlock = CRM.GetBlock("entrygroup");
myBlock.Title = CRM.GetTrans("Tabnames","UserPrefsSession");
var customSelectionEntryBlock = CRM.GetBlock("entry");
with(customSelectionEntryBlock)
{
DefaultValue = myRecord.uset_value;
EntryType = 21;
AllowBlank = false;
if (CRM.Mode==View)
{
Caption = CRM.GetTrans("ColNames","NSet_LoginTo")+":
;"+CRM.GetTrans("DefaultToDo",myRecord.uset_value)+"";
}
else
{
Caption = CRM.GetTrans("ColNames","NSet_LoginTo")+":";
}
CaptionPos = CapTop;
FieldName = "Set_LoginTo";
LookUpFamily = "DefaultToDo"
Size = 1;
NewLine = false;
}
myBlock.AddBlock(customSelectionEntryBlock);
CRM.AddContent(myBlock.Execute());
Response.Write(CRM.GetPage());
if(CRM.Mode==Save)
{
//Retrieve Record
myRecord.uset_value = Request.Form("Set_LoginTo");
myRecord.SaveChanges();
Response.Redirect(CRM.URL("myprefs.asp"));
}
The main thing to point out here is the creation of the field when the screen is in VIEW mode.