Basic template

The basic template allows you to customize standard Sage CRM interfaces and functionality. This template creates the following .cs files:

Base.cs

Provides methods that are called from within Sage CRM. The method name is used to call the application from the CRM tab or menu.

Contains the following code:

using System;
using System.Collections.Generic;
using System.Text;
using Sage.CRM.WebObject;
namespace Crm_Basic_Template1
{
        // Static class AppFactory is REQUIRED!
        public static class AppFactory
        {
                public static void RunMyCustomPage(ref Web AretVal)
                {
                        AretVal = new MyCustomPage();
                }
        }
}

In this code:

  • AppFactory. This class is required for every .NET DLL created for Sage CRM. It contains the methods that are called from within Sage CRM.
  • RunMyCustomPage. This method runs the custom interface that you create in CustomPage.cs.

CustomPage.cs

Contains the following code:

using System;
using System.Collections.Generic;
using System.Text;
using Sage.CRM.WebObject;
namespace Crm_Basic_Template1
{
        public class MyCustomPage : Web
        {
                public override void BuildContents()
                {
                        // Add your content here!
                        GetTabs();
                        AddContent("My Custom Page");
                        AddContent("<BR>");
                        // How to show translated values - maybe
                        AddContent(Metadata.GetTranslation(Sage.Captions.sFam_GenMessages, "HelloWorld"));
                        AddContent("<BR>");
                        // How to check sys param values
                        AddContent("The Base Currency is: " + Metadata.GetParam(Sage.ParamNames.BaseCurrency));
                        AddContent("<BR>");
                        //...etc
                        // Dispatch.
                }
        }
}

In this code:

  • using Sage.CRM.WebObject;. This statement imports the WebObject class for use. If necessary, you can add other using statements. For more information, see .NET code samples.
  • Web classes. These classes provide access to methods to build the HTML code that's returned to the browser. The public class MyCustomPage is an instance of the general web class called Web that's used to build screens from scratch. For information about using specialized Web classes such as DatePage, DataPageEdit, and ListPage, see Entity template.
  • BuildContents(). This public method is overridden. This version of the method is used instead of the version in the base class. BuildContents() is the main method that's always called. Override this method to build your own page. The main purpose of this method is to build HTML that creates the screen displayed to the user. The BuildContents() method in CustomPage.cs initially contains methods to add tabs (GetTabs) and content (AddContent) to the screen. You can replace them with your own methods and code.