Steps to create a basic Sage CRM UI
Complete the next steps to create a screen that displays two blocks. The first block displays the current company details and the second block displays the company’s primary person details.
- Create a new project in Visual Studio using the Basic template.
- Open the CustomPage.cs file and remove all lines of code that start with AddContent.
This is sample code that you won't use. Leave the GetTabs line to retrieve and display Company tabs. - To use the Record object, add a reference to the
Sage.CRM.Data namespace at the top of the file:
using Sage.CRM.Data; - To use the EntryGroup object, add references to the
Sage.CRM.Controls and Sage.CRM.Utils namespaces to the top of the file:
using Sage.CRM.Controls;
using Sage.CRM.Utils; - To get the current Company and Person records, use the
Sage.CRM.Data Record object and FindCurrentRecord method:
Record recCompany = FindCurrentRecord("Company");
Record recPerson = FindCurrentRecord("Person");
Alternatively, you can use GetContextInfo to retrieve the Company and Person records:
// Establish context
string strCompID = GetContextInfo("Company", "Comp_Companyid");
string strPersonID = GetContextInfo("Company", "comp_primarypersonid");
// Retrieve records
record recComp = FindRecord("Company", "comp_companyid = " + strCompID);
record recPers = FindRecord("Person", "pers_personid = " + strPersonID); - To get the screens that
display the information, use the Sage.CRM.Controls
EntryGroup object and the Sage.CRM.Utils MetaData.GetScreen method:
EntryGroup screenCompanyBoxLong = new EntryGroup("CompanyBoxLong");
screenCompanyBoxLong.Fill(recComp);
EntryGroup screenPersonBoxShort = new EntryGroup("PersonBoxShort");
screenPersonBoxShort.Fill(recPers); - To display the screens with the current Company and Person record information, use the following:
- HTML.StartTable. Formats the table in which the blocks are displayed.
- HTML.BoxTitle. Adds a caption to the block.
- HTML.BoxContent. Adds the block to the main area of the table.
- GetHtmlInViewMode. Passes the record to the block.
- HTML.BlankRow. Adds a blank line for formatting purposes.
VerticalPanel vpMainPanel = new VerticalPanel();
vpMainPanel.AddAttribute("width", "100%");
vpMainPanel.Add(screenCompanyBoxLong);
vpMainPanel.Add(screenPersonBoxShort);
AddContent(vpMainPanel); - Build the solution in Visual Studio.
- Copy your compiled .NET DLL to the Storage location for custom .NET DLLs.
- Create a tab to call the compiled .NET DLL.
When launched from the tab, the screen that you've created is displayed.