C# templates
The .NET SDK installs the following C# templates for creating custom .NET DLLs:
Basic template. Enables you to customize standard Sage CRM interfaces and functionality.
Entity template. Enables you to create a .NET DLL that provides a customized graphical user interface for Sage CRM entities.
On a computer where the Sage CRM .NET SDK is installed, you can find these templates in:
%userprofile%\Documents\{Visual Studio version}\Templates\ProjectTemplates\Visual C#
Where {Visual Studio version} is the Visual Studio version you are using.
Basic template
Allows you to customize the standard Sage CRM interfaces and functionality. This template creates the Base.cs and CustomPage.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
class. Required for every .NET DLL created for Sage CRM. It contains the methods that are called from within Sage CRM.RunMyCustomPage
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;
. Imports theWebObject
class. If necessary, you can add otherusing
statements. For more information, see .NET Examples.Web
. Provides access to the methods enabling you to build the HTML code that's returned to the browser. Public classMyCustomPage
is an instance of the generalWeb
class. It is used to build Sage CRM screens from scratch. For information about using specialized Web classes such asDatePage
,DataPageEdit
, andListPage
, see Entity template.BuildContents()
. 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. TheBuildContents()
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.
Entity template
Allows you to create a .NET DLL that provides a customized graphical user interface for Sage CRM entities. Creating a new .NET DLL from the entity template doesn't create a new entity table, screens, and List blocks in Sage CRM - you must create them using the front end or through the Advanced Customization Wizard.
When you use the entity template to create a new C# project in Microsoft Visual Studio, a Sage CRM .NET Entity Wizard starts. Complete the following options in the wizard:
New Entity Name. Enter a name for the entity.
Id field. Enter the name of the ID field in the entity table.
Prefix. Enter the prefix to be used for the fields in the new table.
The entity template creates the following .cs files:
CrmBase.cs. Contains methods to call each .cs file created by the template.
EntityDataPage.cs. Defines the screen that allows a user to view an entity in Sage CRM. The
IdField
andEntityName
values in the .cs file are the ones you entered when you created your C# project from the entity template.AddEntryGroup
specifies the entry group to be displayed. Its default value isEntityNameNewEntry
. Change this value to the name you used for your block in Sage CRM.EntityDataPageDelete.cs, EntityDataPageEdit.cs, and EntityDataPageNew.cs. These files are similar to EntityDataPage.cs. They create an instance of the specialized web class. The
IdField
,EntityName
, andAddEntryGroup
values in these files are the ones you entered when you created your C# project from the entity template.EntityListPage.cs. Displays a list of entities in Sage CRM. This file creates an instance of a specialized web class
ListPage
. TheEntityName
value in this file is the one you entered when you created your C# project from the entity template. The list name and filter box name specify which screens are displayed.FilterByField
andFilterByContextId
allow you to filter the list dynamically, in this case by user ID.EntitySearchPage.cs. Displays the search screen for an entity. This file creates an instance of the specialized web class
SearchPage
.