Table of Contents

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.

  1. Use the basic template to create a new project in Visual Studio.

  2. Open the CustomPage.cs file and remove all lines of code that start with AddContent. Keep the GetTabs line - it is required to retrieve and display Company tabs.

  3. 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 and EntryGroup objects later in this example.

  4. To get the current Company and Person records, use the Record object and FindCurrentRecord method:

    Record recCompany = FindCurrentRecord("Company");
    Record recPerson = FindCurrentRecord("Person");
    

    Alternatively, you can use the GetContextInfo method to retrieve the Company and Person records. To use GetContextInfo, 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);
    
  5. To get the screens that display the information, use the EntryGroup object and the GetScreen method:

    EntryGroup screenCompanyBoxLong = new EntryGroup("CompanyBoxLong");
    screenCompanyBoxLong.Fill(recComp);
    EntryGroup screenPersonBoxShort = new EntryGroup("PersonBoxShort");
    screenPersonBoxShort.Fill(recPers);
    
  6. 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, and BlankRow methods in the Sage.CRM.HTML namespace.

  7. Build your solution in Visual Studio.

  8. Copy your compiled .NET DLL to the storage location for custom DLLs on the Sage CRM server.

  9. Create a tab to call the compiled DLL.