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.

  1. Create a new project in Visual Studio using the Basic template.
  2. 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.
  3. To use the Record object, add a reference to the Sage.CRM.Data namespace at the top of the file:
    using Sage.CRM.Data;
  4. 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;
  5. 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);
  6. 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);
  7. 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.
    // Display the screens
    VerticalPanel vpMainPanel = new VerticalPanel();
    vpMainPanel.AddAttribute("width", "100%");
    vpMainPanel.Add(screenCompanyBoxLong);
    vpMainPanel.Add(screenPersonBoxShort);
    AddContent(vpMainPanel);
  8. Build the solution in Visual Studio.
  9. Copy your compiled .NET DLL to the Storage location for custom .NET DLLs.
  10. Create a tab to call the compiled .NET DLL.
    When launched from the tab, the screen that you've created is displayed.