Building a Screen not bound to Metadata using the ASP COM API

1 minute read time.
Partial Rebuild of My Preferences Screen
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:

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.
  • Mike

    You are spot on. The property EntryType is readonly. The .NET SDK assumes that you are working with system screens. The EntryGroup() class also assumes you are working with existing metadata screens.

    Have a look at the classes in Sage.CRM.HTML namespace. These allow you to create forms and inputs within a .NET screen.

  • Hi Jeff,

    Is it possible to create a screen that does not reference metedata similar to the above code via the .Net API?

    I have been playing around with the Entry class but that appears to only be for accessing fields on existing screen as when I try to set the EntryType property I get an error saying it is Read Only.

    Entry myEntry = new Entry("comp_test");

    myEntry.EntryType = Sage.EntryTypes.Text; --------> this gives a Read Only error.

    I've done a bit of digging in the developer help and the documentation that comes with the SDK but I can't seem to find what I am looking for.

    Any and all help greatly appreciated!!

    Mike