Create basic UI
Complete these steps to create a Sage CRM screen that displays two blocks. The first block displays the current company details and the second block displays the company’s primary person details.
Use the basic template to create a new project in Visual Studio.
Open the CustomPage.cs file and remove all lines of code that start with
AddContent
. Keep theGetTabs
line - it is required to retrieve and display Company tabs.Add the following references to the CustomPage.cs file:
using Sage.CRM.Data; using Sage.CRM.Controls; using Sage.CRM.Utils;
You need these references to use the
Record
andEntryGroup
objects later in this example.To get the current Company and Person records, use the
Record
object andFindCurrentRecord
method:Record recCompany = FindCurrentRecord("Company"); Record recPerson = FindCurrentRecord("Person");
Alternatively, you can use the
GetContextInfo
method to retrieve the Company and Person records. To useGetContextInfo
, add the following reference to the CustomPage.cs file first:using Sage.CRM.WebObject;
Then, add the following code:
// 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
EntryGroup
object and theGetScreen
method:EntryGroup screenCompanyBoxLong = new EntryGroup("CompanyBoxLong"); screenCompanyBoxLong.Fill(recComp); EntryGroup screenPersonBoxShort = new EntryGroup("PersonBoxShort"); screenPersonBoxShort.Fill(recPers);
To display the screens containing information about the current Company and Person, add the following code:
// Display the screens VerticalPanel vpMainPanel = new VerticalPanel(); vpMainPanel.AddAttribute("width", "100%"); vpMainPanel.Add(screenCompanyBoxLong); vpMainPanel.Add(screenPersonBoxShort); AddContent(vpMainPanel);
You can also use the
StartTable
,BoxTitle
,BoxContent
, andBlankRow
methods in theSage.CRM.HTML
namespace.Build your solution in Visual Studio.
Copy your compiled .NET DLL to the storage location for custom DLLs on the Sage CRM server.
Create a tab to call the compiled DLL.