SageCRM 7.3SP3 DeveloperGuide en
SageCRM 7.3SP3 DeveloperGuide en
3 SP3
Developer Guide
Revision: DEV-MAN-ENG-7.3SP3-1.0
Updated: August 2016
© 2016, The Sage Group plc or its licensors. Sage, Sage logos, and Sage product and service names
mentioned herein are the trademarks of The Sage Group plc or its licensors. All other trademarks are the
property of their respective owners.
Getting started 11
Sage CRM architecture 12
Web 12
Extensibility 13
.NET API 14
Security 15
Database 16
Creating an ASP page 18
Adding an ASP page to Sage CRM 21
Framesets 22
Creating custom queries 23
Creating a record set 23
Formatting a list 24
Manipulating record sets 25
Understanding context 26
Scripting in the Sage CRM interface 27
Using field-level scripting 27
Using table-level scripting 29
Example: Client-side validation 29
Example: Accessing user information 30
Example: Getting information about installed modules 32
Customization 33
Using ASP pages 33
Using customizable areas 33
Transferring customizations to another Sage CRM instance 35
Database 93
Creating a new database table 94
Creating a new database connection 96
Creating a new table connection 97
Table- and entity-level scripts 98
Table-level scripts 98
Detached table-level scripts 99
Entity-level scripts 99
Creating a script 100
Viewing script logs 101
Disabling table-level scripts 101
Database customization examples 102
Creating a tab to display a list of invoices 102
Displaying an invoice from a list 104
Adding new data entry and maintenance screens 106
Using UpdateRecord in an entity-level script 111
Using InsertRecord in a table-level script 112
Using PostInsertRecord in a table-level script 113
Using UpdateRecord in a table-level script 114
Using DeleteRecord in a table-level script 114
Entities 117
Creating a custom entity 118
Entity parameters 119
ASP files and metadata generated for custom entities 122
Example: Creating a custom entity named Project 124
Modifying a custom entity 126
Making a custom entity available for reassignment 127
Enabling deduplication for a custom entity 128
Changing the custom entity logo 129
Creating a report view for an entity 130
Graphics 131
Considerations for using graphics 132
Supported graphic file formats 133
Using external images 134
Charts 151
About animated and interactive charts 152
Creating an Opportunity certainty widget 153
Creating an Opportunities and Cases widget 155
Creating an organization chart 158
APIs 161
Using Web Services API 162
About Web Services 162
Prerequisites for using Web Services 163
Enabling Web Services for a user 163
Configuring Web Services 164
Required fields in quotes and orders 166
Using the WSDL file 167
Web Services methods 168
Reference 213
ASP objects 214
AddressList object 216
Attachment object 218
AttachmentList object 221
CRM object 223
CRMBase object 230
CRMBlock object 236
CRMChartGraphicBlock object 243
CRMContainerBlock object 249
CRMContentBlock object 259
CRMEntryBlock object 260
CRMEntryGroupBlock object 274
CRMFileBlock object 278
CRMGraphicBlock object 281
CRMGridColBlock object 298
CRMListBlock object 303
CRMMarqueeBlock object 310
CRMMessageBlock object 314
CRMOrgGraphicBlock object 320
CRMPipelineGraphicBlock object 322
CRMQuery object 325
CRMRecord object 333
This guide is for Sage CRM implementers, developers, and system administrators. It provides information
on how to customize and extend the functionality of Sage CRM by using the Extensibility Module (EM), also
known as CRM Blocks.
This guide assumes that you are familiar with the following:
Step-by-step instructions in this guide assume that your default theme in Sage CRM is Contemporary. If
you are using a different theme, you may need to use slightly different steps to access the Administration
area in Sage CRM.
Note: This help refers to Sage CRM but your system might have a different brand name, such as Sage
200 Sales and Marketing. The system works in the same way regardless of its name. The functionality
that's available to you depends on the modules that you're licensed to use.
Web
l Web browser. Sage CRM has a thin client configuration, therefore users can access and work with
Sage CRM by using just a web browser. This can be any web browser supported by Sage CRM.
l Application server. The Sage CRM application server includes a number of components, which
work together to coordinate the delivery of information and functionality to Sage CRM users. These
components are used to implement user security, maintain user persistence, read and write
information in the Sage CRM database, generate web pages from data, and process business rules
and logic. The application server also runs the eWare.dll file, which is the Sage CRM dynamic link
library. Web Server (IIS) communicates with Sage CRM via eWare.dll and Internet Server
Application Programming Interface (ISAPI) technologies. eWare.dll and Web Server (IIS) must be
on the same server.
l Microsoft SQL Server. This server hosts the Sage CRM database that stores corporate data and
metadata, which define the Sage CRM screen configurations, system customization, security, and
business rules.
Extensibility
The Extensibility Module (EM) provides a range of powerful functions that allows you to customize and
extend the existing CRM product. The functions are available through the CRM ActiveX object, which
consists of CRM methods and properties. CRM object components have a variety of functions, which render
HTML and display Screen and List objects previously defined in the CRM system.
Database connectivity options include searching, inserting, updating, and deleting data to and from CRM
data, as well as data from external tables and databases.
The Sage CRM .NET API requires Microsoft .NET Framework 2.0. It provides a type library that exposes
Sage CRM objects, properties, and methods. Through its core libraries, the Sage CRM .NET Component
manages data access and web interface generation. Projects developed using the Sage CRM .NET
Component are compiled into a DLL and called directly from within Sage CRM. By using Sage CRM
metadata, Application Extensions constructed using the Sage CRM .NET API look, feel and perform like
core system pages.
Reference to the Sage CRM .NET component from within ASP.NET projects is not supported.
Security
Sage CRM is modeled on an n-tier architecture. Each tier includes a number of security mechanisms.
l Application-level security
l Server-level security
l Database-level security
l User Authentication/Password Setup. A user requires a login ID and password to access the
system. The user's password is encrypted in the system and in the database for maximum security.
l Tab and Team Restrictions. The System Administrator can restrict access to individual tabs within
CRM, and the level of access that each user is allocated. The Administrator can assign users to
teams, which further categorizes and restricts levels of access to individual tabs.
l Security Profiles and Territories. The System Administrator can set up Territory Profiles and
Security Territories to manage security access rights across the organization. A Profile groups users
according to access rights (View, Update, Insert, Delete). A Territory groups user rights by location
or other criteria. For example, users in the Europe territory can view all Opportunities in the USA
territory but can't update them. Administrators can set up complex inter-territory security rights and
exception handling using Territory Policies. Profiles and Territories are set up from <My Profile> |
Administration | Users | Security. For more information, see the System Administrator Help.
Server-level security
You can use any of the following methods to secure the Sage CRM server:
Database-level security
Sage CRM users don't have direct access to the database. The CRM DLL accesses the database using a
predefined login. When a user requests data, the CRM DLL connects to the database using Microsoft Data
Access Components (MDAC) and retrieves the required data. For extra security, you can configure the
CRM DLL to access the database with a user account that has limited permissions.
Database
l Sage CRM entities
l Metadata
l SQL and triggers
l Company
l Case
l Opportunity
l Person
l Communication
l Leads
l Quotes
l Orders
Unlike database entities, Sage CRM entities are several tables linked together in a logical business
grouping.
Metadata
Sage CRM metadata encompasses all information required to make sense of stored business data. For
example, metadata tables contain field captions, or convert code values from drop-down fields into
meaningful information.
The system database contains Sage CRM metadata tables. Names of these tables have the custom prefix.
<%
// Get an empty container block.
var SearchContainer = CRM.GetBlock('Container');
// If button has been pressed then add the list block to show search
results.
if (CRM.Mode == 2)
{
var resultsBlock = CRM.GetBlock('PersonGrid');
resultsBlock.ArgObj = SearchBlock;
SearchContainer.AddBlock(resultsBlock);
}
if (!Defined(Request.Form))
{
// First time - display mode.
CRM.Mode = Edit;
}
else
{
// Mode is always Save.
CRM.Mode = Save;
}
CRM.AddContent(SearchContainer.Execute());
var sHTML = CRM.GetPage();
Response.Write(sHTML);
%>
This building block specifies the include file that instantiates and initializes the CRM object. The include file
also references the Sage CRM CSS, defines constants, and checks for errors. Depending on the scripting
language you use, you can specify one of the following include files in your code:
l SAGECRM.JS. Referenced in JavaScript-based ASP pages. This file sets the default language to
JavaScript.
l SAGECRMNOLANG.JS. Doesn't set the default language.
l SAGECRM.VBS. Referenced in Visual Basic-based ASP pages. This sets the default language to
VB Script.
l eWare.JS. For backward compatibility with Sage CRM versions older than 5.6.
l ACCPACCRM.JS. For backward compatibility with Sage CRM versions older than 7.0.
l ACCPACCRMNOLANG.JS. For backward compatibility with Sage CRM versions older than 7.0.
l ACCPACCRM.VBS. For backward compatibility with Sage CRM versions older than 7.0.
<%
// Get an empty container block.
var SearchContainer = CRM.GetBlock('Container');
In this building block, ASP delimiters <% %> tell the ISAPI.DLL that the contained ASP code executes on
the server.
The GetBlock(BlockName) method initializes a child block that implements core CRM functionality.
The GetBlock(BlockName) method parameter value is Container, which indicates the
CRMContainerBlock object. This object groups and correctly displays output from other objects on the
page. The Container block also provides default onscreen elements, such as buttons, that make it easier to
format and support custom layouts.
The returned CRMContainerBlock object is stored in the variable SearchContainer. The Container
screen contains only default buttons. To make it useful, add some blocks.
var SearchBlock = CRM.GetBlock('PersonSearchBox');
The GetBlock(BlockName) method retrieves a block and its associated functionality. This code specifies
PersonSearchBox which is an instance of the CRMEntryGroupBlock object. To edit the contents of
PersonSearchBox, go to <My Profile> | Administration | Customization | Person | Screens |
Person Search Screen. Other standard screens based on the CRMEntryGroupBlock object include
CompanySearchBox, PersonEntryBox, and CaseDetailBox.
SearchContainer.AddBlock(SearchBlock);
This building block changes the attributes of the Save button. The Container object creates this by default.
// If button has been pressed then add the list block to show search
results.
if (CRM.Mode == 2)
l On a 32-bit (x86) system: %ProgramFiles%\CRM\CRM\WWWRoot
l On a 64-bit (x64) system: %ProgramFiles(x86)%\CRM\CRM\WWWRoot
To view the new tab you have just created, open an entity record details screen.
To improve the Sage CRM User Interface, framesets are no longer used in Sage CRM version 7.2 and
later. ASP pages are rendered entirely within the main browser window, which ensures that the top content
and left-hand menu of Sage CRM are always rendered correctly.
l These changes affect client-side code that references certain functions or objects, and interacts with
frames such as TopContent or eWare_mid. Review how you've included JavaScript in classic
Content blocks, or have used references to ASP pages and the COM API in a custom gadget.
l Several objects in Sage CRM version 7.1 are created in other frames. For example, WritetoFrame()
and Arrays (userslist, usersdislist, targetlistslist). Change and test any code that references these
objects.
l Check the metadata for screens and lists that contain client-side customizations. Run the following
SQL statements in the database to find screens with defined custom content and onChange scripts:
select * from Custom_ScreenObjects where Cobj_CustomContent is not
null select * from Custom_Screens where SeaP_OnChangeScript is not
null;
l The default basic CTI in Sage CRM version 7.1 used framesets. The CTI button frame and a frame
for the CTI object no longer exist in the same way in Sage CRM version 7.2. The removal of the
framesets effects any customization that depends on CTI interactaction with the screens. If you're
using a third party CTI integration, consult your supplier about whether it has been updated for Sage
CRM 7.2 before upgrading from an earlier Sage CRM install.
In this example, the CreateQueryObj(SQL, Database) method returns a CRMQuery object by specifying a
valid SQL statement as a parameter. The default database is used, but you can specify another database by
adding a second parameter to the CreateQueryObj(SQL, Database) method call.
You can expand the scope of your query by using relational database features such as joins and views.
To examine or copy system and custom views, go to<My Profile> | Administration | Customization |
<Entity> | Views. Alternatively, scan the list of views in a database management tool such as SQL Server
Enterprise Manager.
In this example, the returned query object is called Query. The SelectSql() method executes the Select
query. You can use the ExecSql() method to run queries that don't return records, such as Delete,
Update, and Insert.
In addition to encapsulating components to access and update the database, the CRMQuery object stores
returned data.
Formatting a list
Use the CRMListBlock object to apply desired formatting to a filtered list. To initialize the CRMListBlock
object, invoke the GetBlock(BlockName) method with the appropriate parameter.
The following example uses the GetBlock(BlockName) method to create a new list object:
<!-- #include file ="sagecrm.js"-->
<%
var NewList;
NewList = CRM.GetBlock("list");
NewList.SelectSql = "SELECT * FROM Company WHERE Comp_Deleted IS NULL AND
Comp_Type = 'Prospect' AND Comp_Sector = 'Software'";
NewList.AddGridCol("Comp_Name");
CRM.AddContent(NewList.Execute());
Response.Write(CRM.GetPage());
%>
The Select query for retrieving a filtered list of company records is the same as the query used by
CRMQuery object. However, the query string is passed to the SelectSql property of the CRMListBlock
object.
The GetBlock(BlockName) method retrieves the CRMListBlock object stored in the NewList variable.
The AddGridCol(ColName, Position, AllowOrderBy) method specifies which columns to display. The
example shows values relating to the company name and email address.
You can pass only field names that are returned by the SQL query.
You can enter optional addition parameters for this method that specify the position of the column in the
tabular list and whether the column contents are ordered.
The Execute(Arg) method returns HTML to display the selected columns in a properly formatted list.
The CRMListBlock object has abstracted the process of looping through the available records, so a WHILE
statement testing an EOF marker is not needed.
The returned list is passed to the AddContent(Content) method. The GetPage() method is used in
conjunction with Response.Write to display the output in the Sage CRM user interface.
Assigns new values to fields. This is similar to opening an ADO updateable recordset. For example, the
following code samples are equivalent:
Comp.item ('comp_Name') = '4D Communications International'
INSERT INTO Company (Comp_Name) Values ('4D Communications')
You're not required to specify the item property because it's the default property for this object.
The following two lines of code are equivalent:
Comp.item('comp_Name') = '4D Communications International'
Comp('comp_Name') = '4D Communications International'
l Server-side code. Use server-side code if you'll use objects from the CRMBlocks hierarchy.
Scripts, such as SQL queries, that manipulate databases need server resources to access the
specified records.
l Client-side code. Use client-side code for immediate responses to user actions, to access the DOM
to navigate the screen interface, and to validate on screen information.
l Use JavaScript, the DOM, the CurrentUser variable, and the ModuleCode variable to
configure screens and create event handlers that respond to the current user's profile and
modules available on the system.
l Use of client-side validation saves time by checking information that's available on screen
before the page is sent to the server for server-side validation. You can enter code directly
through the interface so you can verify the connection between interface elements and event-
handling code.
For more information, see the System Administrator Help.
l For information about client-side classes and modules, see the Client-Side API Help.
Scripts in CreateScript run on the server and execute when the page is loaded into CRM.
Scripts in OnChangeScript run on the client and are executed when the JavaScript event OnChange
occurs on the specified field.
Scripts in ValidateScript run on the server and are executed when the user clicks Submit. For more
information, see Validation scripts.
This example is a simple if statement for the comp_type field that disables another field if its value is Partner.
Example 2
if(this.value.toUpperCase() == this.value)
{
window.alert(this.name + ' has been entered all uppercase');
}
In this example, the OnChange script alerts the user to change an entry before validation is triggered.
Validation scripts
When writing validation scripts that execute on the server, the following system variables can help you trap
information and provide feedback.
l Values( ). Holds the inbound values of data coming into the system. It allows you to read any variable
in the QueryString in CreateScripts. You can test for the dominant key and context.
var x = Values("Key0");
Valid = false;
ErrorStr = x;
l Valid. Determines whether the ErrorStr value should be displayed on the screen. The default value
is True. When set to False, it marks the current entry as invalid. Valid set to False has the following
behavior in different parts of the system:
l It displays an ErrorStr in create scripts and blocks the commitment of data in validate scripts.
l It controls the display of workflow rule buttons in Primary, Transition, and Global workflow
rules.
l It causes a conditional rule to execute an alternative set of actions.
l In Table Level and Entity Level scripts that update records in response to an action, it can set
ErrorStr to the browser, or can block the entire transaction.
l ErrorStr. Returns the string in the error content bar at the top of the screen.
The following example validates a field value when a user is specifying details for an opportunity:
This script checks the value in the oppo_type field, and an action is taken if the opportunity type is Mix. This
script only validates the value of the specified field, other fields are ignored.
If the oppo_type field value is invalid (Valid = false), an error message (ErrorStr = 'This Mix
type is temporarily not supported';) is displayed in a red bar at the top of the screen.
This example tests onscreen information only. You can use other blocks accessible through the API to base
validation on entity information not currently displayed onscreen. Also, the CRMEntryBlock object's
properties such as Required, ReadOnly, MaxLength, CreateScript, OnChangeScript, and
ValidateScript enable you to control and respond to values entered into a screen.
l Table-level scripts are executed when a record is inserted, updated, or deleted on a specified Sage
CRM table.
l Entity-level scripts are executed when a Sage CRM entity is inserted, updated, or deleted.
You enter the scripts through the Sage CRM interface. For more information, see Table- and entity-level
scripts.
Generally, you'll respond to triggers using server-side scripts that leverage the API. The triggers are:
InsertRecord(), PostInsertRecord(), UpdateRecord(), and DeleteRecord().
For more information about the methods used in this example (such as crm.ready, crm.hideButton,
and crm.showButton), see the Sage CRM Client-side API Help.
l user_userid
l user_primarychannelid
l user_logon
l user_lastname
l user_firstname
l user_language
l user_department
l user_resource
l user_externallogonallowed
l user_isterritorymanager
l user_per_user
l user_per_product
l user_per_currency
l user_per_data
l user_offlineaccessallowed
l user_per_customise
l user_minmemory
l user_maxmemory
l user_title
l user_location
l user_deskid
l user_per_infoadmin
l user_device_machinename
The next example configures search options in a search screen according to the user's profile. All users in
the Telemarketing department deal with customers in Europe, so the code automatically selects Europe
from the Territories list when a member of the Telemarketing department accesses this search page.
<script language="JavaScript">
var channeldept = CurrentUser.user_department;
window.attachEvent("onload", Populate);
function Populate()
{
if (channeldept=="Telemarketing")
{
var oSource = document.all.item("pers_secterr");
var dropdownloop = document.all.item("pers_
secterr").length;
var setIndex = 0;
for (i=0;i<dropdownloop;i++)
{
checkText = oSource.options[i].text;
if(checkText.indexOf("Europe") != -1)
{
setIndex = i;
break;
}
}
document.all.item("pers_secterr").selectedIndex =setIndex;
}
else
{
document.all.item("pers_secterr").selectedIndex = 0;
}
}
</script>
The CurrentUser object ascertains the user's department. The information contained in
CurrentUser.user_department is stored in the variable channeldept.
The attachEvent method calls the Populate function when the page is loaded ("onload").
The first line in the Populate event handler determines if the user's department is Telemarketing. If it is,
item from the all() collection of the Document object finds the pers_secterr field, which is the drop-
down list containing available territories. A more advanced solution could use a switch statement to indicate
a range of actions depending on a variable's value.
The subsequent if statement loops through list options to find Europe. The JavaScript method indexOf
checks whether the current option text contains Europe. If it does, the setIndex variable is set and
ensures that the Europe option is visible when the page is loaded.
Example
<script>
if(ModuleCode & 1) alert('Sales module is installed');
if(ModuleCode & 2) alert('Service module is installed');
if(ModuleCode & 5) alert('Sales and Marketing modules are installed');
if(ModuleCode & 7) alert('Sales, Marketing, and Service modules are
installed');
</script>
Gets the value of the ModuleCode variable and displays information about installed modules on the screen.
Tabs Add new tabs to tab groups in l Add new tab groups.
the Sage CRM database. l Link tabs to custom files or
Customize main menu buttons. URLs.
l Link tabs to runblock and
runtabgroup functionality.
You can transfer virtually any changes that you make in the <My Profile> | Administration |
Customization area of Sage CRM. The table below lists the customizations that you can and cannot
transfer between two instances of Sage CRM.
l Method 1: Record your future customizations. Use this method if you haven't yet made the
customizations you plan to transfer to another Sage CRM instance. This method involves a number
of steps you need to complete before you start customizing Sage CRM.
l Method 2: Retrieve existing customizations. Use this method if you want to transfer
customizations already applied to Sage CRM. With this method, you can configure criteria to retrieve
specific customizations from the Sage CRM database and save them in a component. For example,
you can retrieve customizations made by a specific Sage CRM user, within a certain date range, or
both.
The component is set as current and listed under Existing Components. The current component
automatically records all your customizations even if they span several days and you log in and out of Sage
CRM during that period. The screens you customize are labeled with the name of the current component
You can stop and resume the recording to record only the customizations you need.
To stop the recording:
All customizations you make are recorded against the current component. If necessary, you can change the
current component.
You can configure criteria to retrieve existing customizations from the Sage CRM database and copy them
to your new component. Then, you can use that component to generate script files and apply your
customizations to another Sage CRM instance. For example, you can configure criteria to retrieve
customizations created or updated by a particular user, within a certain date range, or both. Optionally, you
can search a particular existing component for the customizations that satisfy your criteria.
Use this method with caution, because the customizations you retrieve and save in your new component are
removed from all the existing components where they were stored previously.
Now you can generate script files from your new component as described in Step 2: Generate script files.
If necessary, you can set your new component as current and record any additional future customizations.
For more information, see Changing the current component.
On a Sage CRM computer, you can find the generated script files in one of the following locations:
The inf folder holds the Sage CRM Component (.ecf) file and the component folder named after the
component. The component folder contains the Sage CRM Script (.es) file and any other corresponding
files, for example, ASP pages. To transfer your customizations, make sure to add all these files to the .zip
archive.
The Component Manager automatically copies files stored in the CustomPages folder of Sage CRM only if
these files are included in a tab group with the customfile action. If your customization files include other files
such as .asp, .dll, .txt, .js, or .inc, manually copy them into the component's CustomPages folder when the
component scripting is finished.
On a Sage CRM server, you can find the CustomPages folder in one of the following locations:
For each component, you can view such information as component name, description, created date, who
created the component, whether the component is set as current, and when the component was scripted
last time. Optionally, you can change the component description.
Before generating the customization script from a component, you can preview that script.
You can modify the Sage CRM Component (.ecf) and Sage CRM Script (.es) files generated by the
Component Manager:
On a Sage CRM server, you can find these files in one of the following locations:
For example, you can specify additional parameters in the .ecf file or modify JavaScript in the .es file to do
the following:
Variable and constant names are case sensitive and can be used for any component APIs.
Make sure you order your code correctly when modifying the Sage CRM Script (.es) file. For more
information, see Observing referential integrity.
When modifying scripts, you can pass the following parameter types to the .es script file:
l TEXT
l CHECKBOX
l MULTITEXT
l PASSWORD
l INTEGER
l SELECT
l DATETIME
l DATE
Create a parameters section in the .ecf file with the keyword Params: and put the parameters on separate
lines beneath the keyword in the following format:
<Parameter Type>
<Attribute=Value>,<Attribute=Value>,<Attribute=Value>
Example
Params:
TEXT Name=ServertName,Caption=Enter server name,
Required=True CHECKBOX Name=IncludeThis,Default=On,
Caption=Include extras PASSWORD Name=Password INTEGER Name=NumUnits,
OnChange=alert('You have entered'+NumUnits.value+' units.');
When you install the component, the fields are displayed on the Parameter Info screen with the attributes
you specified. To use the values entered, call the Param() method in the .es script file. For example, to
retrieve the value in the Enter Server Name text box, call Param(ServerName) in the .es script file.
You can specify the following attributes for each parameter:
The architecture implemented in Sage CRM 7.0 and later facilitates the Interactive Dashboard. To allow the
persistence of the Meta Data Model within this architecture, make sure you observe strict referential integrity
within Sage CRM metadata tables.
This means you must correctly order the code in components in the Sage CRM Script (.es) file. For
example, you can't add a view if the table the view is based on hasn't already been added.
l Custom_Edits - (Custom_Tables)
l Custom_Views - (Custom_Tables)
l Custom_ScreenObjects - (Custom_Tables, Custom_Views[optional])
l Custom_Lists - (Custom_ScreenObjects, Custom_Edits)
l Custom_ContainerItems - (Custom_ScreenObjects x2)
l Custom_Tabs - (Custom_ScreenObjects)
l Custom_Screens - (Custom_ScreenObjects, Custom_Edits)
l FieldSecurity - (Custom_Edits)
l UserSettings - (Users)
l TerritoryPermissions - (Custom_Tables ,Users, TerritoryProfiles, Territories)
l Channel_Link - (Users, Channel)
l Users - (Channel, TerritoryProfiles, Territories)
You cannot use the AddCustom_Data or RunSQL method to update the tables listed above, as the
foreign keys are not set automatically. Use the table appropriate method instead. For example, to update
Custom_Edits use AddCustom_Edits.
By default, when you use the Sage CRM Script (.es) file to transfer your customizations, all script errors are
handled in the following manner:
Whenever an error occurs, the script keeps running and applies all other changes specified in the .es file.
You can change this default behavior and configure your script to roll back all changes already made
whenever an error occurs. To do so, add the errorhandling=strict line to the corresponding Sage
CRM Component (.ecf) file.
Example
Description=My component
Directory=My component
Version=7.3
errorhandling=strict
When using the Component Manager to record your customizations, you can create multiple sets of files,
each containing specific changes. For example, you can use this method to record complex, multi-stage
customizations and then apply them to the target Sage CRM system in stages.
Code samples
This section provides examples of how to modify your scripts to do the following:
You can specify that a component can be used for multiple installs. This is useful if you install a component,
make further customization changes, and then want to undo them. Rather than undoing the changes
manually, you can reinstall the component on a clean Sage CRM install.
2. Open the .es script file and change the following script.
From:
AddCustom_ScreenObjects('DemoScreen1','Screen','Opportunity',
'Y','0','','','');
To :
AddCustom_ScreenObjects('Param(ScreenName'),'Screen','Opportunity',
'Y','0','','','');
Adding a message
2. Open the .es script file and add the following script.
AddMessage('A new screen called '+Param('EntityName')+' was installed
into CRM.');
1. Open the .es script file and add the following script.
CopyAspTo
('custompages\\subfolder\\edit.asp','custompages\\subfolder\\edit.as
p');
2. When you install the component, EDIT.ASP is copied from the Phase1 component directory to the
following location in the current installation: \custompages\subfolder\edit.asp.
1. Open the .es script file and add the following script.
SearchAndReplaceInFile('Edit.asp','Find','Search');
2. When you install the component, any instances of the word Find in the file Edit.asp are replaced
with the word Search.
1. Open the .es script file and add the following script.
CreateTable('DemoTable','dem','demo','false','false','false');
2. When you install the component, a table called DemoTable is added to Sage CRM. The following
columns are automatically created for the table:
l Dem_TableId
l Dem_ System
l Dem_ CreatedBy
l Dem_ CreatedDate
l Dem_ UpdateBy
l Dem_ UpdateDate
l Dem_ TimeStamp
l Dem_ Deleted
1. Open the .es script file and add the following script.
AddColumn('DemoTable','Dem_Description',10,'(25)','True','False');
2. When you install the component, a column called Dem_Description is added to the DemoTable
created in Creating a new table.
This example uses the DataFile object to loop through the rows in a spreadsheet and perform actions
with the values found.
Open the .es script file and add the following script.
var MyFile = FileOpen('c:\\data\\mydata.xlsx');
var i = 0;
while (!MyFile.EOF)
{
i = 0;
while (i < MyFile.FieldCount)
This component script adds a view. It uses the iDatabase variable. Open the .es script file and add the
following script.
sViewText="CREATE VIEW vMyPhone AS SELECT";
if (iDatabase == IOracle) {
sViewText = sViewText + " Phon_CountryCode || N ' ' ||Phon_AreaCode || N '
' || Phon_Number";
}
else {
sViewText = sViewText + " RTRIM(ISNULL(Phon_CountryCode, '')) + ' ';
sViewText+= "RTRIM(ISNULL (Phon_AreaCode, '')) + ' ' + RTRIM(ISNULL(Phon_
Number, ''))";
}
sViewText +=" AS Phon_FullNumber, Phone.* FROM Phone ";
sViewText += "LEFT JOIN Custom_Captions ON Phon_Type = Capt_Code WHERE";
sViewText += " Phon_Deleted IS NULL";
AddView("vMyPhone", "Phone", "This selects all of the phone numbers",
sViewText, false, false, false, false, false
3. Click Preview Install to view the script that's executed when the component is installed and a
prediction of whether each step will be successful.
4. Select Yes or No in Apply All Changes. These options apply to changes made by previous
components to the objects that are being changed by the current component.
l To install everything in the component and overwrite any changes from previous components,
select Yes.
l To preserve changes from previous components, select No. Select No only when you've a
specific reason for doing so as it may result in your component being only partially installed.
5. Click Install. Component Manager loads the new information, recreates the views, and reloads the
metadata. When the Component Installed message appears, you can view the log file that has been
generated. Otherwise click Continue to return to the Components tab.
When the component installation completes, you can view the component installation log to see the changes
made or issues encountered during the installation.
When applying customizations to the target Sage CRM system, consider the following:
Workflow with the same name exists both in Workflow from source overwrites the workflow in
source and target. target.
Exception: Deleting workflow rules or states in
source does not affect the corresponding rules or
states in target.
A log file is automatically generated when you install a component. The log file is saved as a Comma-
separated Values (.csv) file.
To view the component installation log, do the following:
Alternatively:
The log file contains two columns and a row for each action attempted during the component manager
installation. The first column contains one of the following values:
The second column contains the script command that was run.
l Objects
l Blocks
l Lists
l Screens
l Buttons
l Classic Dashboard
l Customizing the Interactive Dashboard
l System menus
l Tabs
l Adding Help to custom pages
Dispatch Controls all web requests and responses, finds the relevant
UserSession, and sets the session keys. User requests are
sent to the application's Web module, which creates an object
to process the request, and output the relevant response. You
can't access the Dispatch object because it's internal to Sage
CRM.
CRM TargetLists Used to create target lists also known as groups in Sage
CRM 7.2 and later. To ensure that legacy code works with
new installations, the term target lists is maintained in the API
terminology.
CRMQuery object Enters and executes SQL statements against a known CRM
database. Used to perform more powerful queries than is
possible with the CRM Record object.
CRMBlock object The base of all CRM blocks. This block determines the actual
implementation of each CRMBlock method and property.
CRMContainerBlock object Used to group other blocks on a screen. This block contains
the standard Sage CRM buttons. You can configure workflow
buttons on the screens where they'll be displayed. An
example of a container block is a linked search panel and
related list.
CRMEntryGroupBlock object Used to group entries to create a screen. You can generate
many types of entry group, such as a Company Search Box, a
Person Entry Box, and a Case Detail Box. This block contains
the standard Sage CRM buttons.
CRMListBlock object Generates a custom list from columns in a Sage CRM table,
or a table connected to Sage CRM through <My Profile> |
Administration | Advanced Customization | Tables And
Databases.
CRMGridColBlock object Corresponds to a single column in the List block. Use the
GridCol block to change properties on individual columns in a
list.
CRMMarqueeBlock object Adds scrolling text to a page. The content of the text is
maintained through <My Profile> | Administration |
Customization | Translations. Use the properties of this
block to control the direction, speed, and style of the scrolling
text.
CRMFileBlock object Provides access to external files that aren't part of Sage CRM
and enables files to appear as if they are part of Sage CRM.
CRMMessageBlock object Allows you to send messages in email and SMS format.
Include this block in ASP pages to display a simple email form
or to automate the message sent in response to a certain
event.
CRMContentBlock object A simple block that takes a string of content (text) and displays
it on the page. Used to write out a line of HTML to the
browser.
CRMChartGraphicBlock object Displays a variety of charts which can be generated from data
retrieved using SQL or added through an ASP page. It
inherits all the functionality of the Graphics block.
About blocks
You need the Extensibility Module (EM) to create and customize blocks in <My Profile> | Administration |
Customization | <Entity> | Blocks.
All lists, screens, and fields that you create are blocks within the system (ListBlock, EntryGroupBlock, and
EntryBlock). New blocks must be based on an existing standard CRM block. Fo example, Container,
EntryGroup, or Marquee. Associate all new blocks with the entity to which they relate.
You can create and display new blocks of data from external tables and databases to which Sage CRM is
connected. For more information about customizing tables, see Database.
When you create a new block, you can reference and run it from Sage CRM and in ASP pages.
Generic name of the block All blocks are based on a CRM basic block type.
To reference CRM generic block names, go to
<My Profile> | Administration | Customization
| <Entity> | Blocks and click New.
The custom block names are listed in Block Type.
The block names correspond to the main block
names in the CRM block hierarchical diagram. All
other blocks are based on one of these block types.
Name of any custom screen (Entry block) A standard installation includes a number of
predefined custom screens that you can
manipulate or copy.
To reference predefined custom screen names, go
to <My Profile> | Administration |
Customization | <Entity> | Screens.
The screen names are displayed in Screen
Caption.
Alternatively, reference the name from the Custom
Tables in your database. For example, if you're
using SQL Server, the block names are in the
database in Enterprise Manager.
Name of any custom list (List block) A standard installation includes a number of
predefined custom lists that you can manipulate or
copy.
To reference predefined custom list names, go to
<My Profile> | Administration | Customization
| <Entity> | Lists.
The list names are displayed in List Name.
Alternatively, reference the name from the Custom
Tables in your database.
Name of any block that you have created You can create your own blocks from the system
interface.
Creating a block
All new blocks you create in CRM must be based on Sage CRM custom blocks. You can then customize the
properties of the block.
You can customize any lists or screens that you create by creating a block from the list or screen and editing
the properties of the block. These blocks are also available for use within ASP pages.
To access the new block within an ASP page, use the GetBlock(BlockName) method. The object returned
by the GetBlock(BlockName) includes the specified properties.
You can also create a block in an ASP page linked to CRM. For more information, see Creating an ASP
page.
Customizing a block
You can change the properties of an existing block or specify the properties of a new block.
Displaying a block
You can display a new block on a new tab using runblock to directly run the block. You can run Content,
Marquee, Message, and Chart blocks using runblock. You can also run any EntryGroupBlock based on a
current entity screen using runblock.
Alternatively, you can display a new block on a new tab using customfile to link to an ASP page that
references the block.
Creating a list
You can create a new list in Sage CRM from columns in existing tables or external tables connected to
CRM.
You can also create a list in an ASP page linked to CRM. For more information, see Creating an ASP page.
Customizing a list
1. Log on to Sage CRM as a system administrator.
2. Go to <My Profile> | Administration | Customization | <Entity> | Lists.
3. Click the list you want to customize.
4. Make your changes and click Save.
For more information about customizing lists, see the System Administrator Help.
1. Create your .asp file and add it to Sage CRM. For more information, see Creating an ASP page and
Adding an ASP page to Sage CRM.
2. Log on to Sage CRM as a system administrator.
3. Go to<My Profile> | Administration | Customization | <Entity> | Tabs.
4. Click the tab group to which you want to add the tab.
5. Use the following options:
l Caption. Enter a name for the tab.
l Action. Select customfile.
l Custom File. Enter the name of your .asp file.
6. Click Add and then click Save.
Creating a screen
You can create a new screen in Sage CRM from columns in existing tables or external tables connected to
CRM.
You can create a block from the new screen and use the block properties to customize the appearance of
the screen.
You can also create a screen in an ASP page linked to CRM. For more information, see Creating an ASP
page.
Customizing a screen
When you've created a screen, you must define screen fields.
1. Create the .asp file and save it in the Custom Pages folder of your Sage CRM installation directory.
2. Log on to Sage CRM as a system administrator.
3. Go to <My Profile> | Administration | Customization | <Entity> | Tabs and choose the block
context.
4. Click the tab group to which you want to add the tab.
5. Enter a name for the tab.
6. Select customfile from Action.
7. Enter the name of the ASP page in Custom File.
8. Click Add and then click Save.
l Available In
Dashboards. Includes the
block in Available Content
for all users.
l Dashboard - Info
Manager. Includes the
block in Available Content
for all users with security
administration rights set to
Info Manager or System
Administration.
l Dashboard -
Administration Only.
Includes the block in
Available Content for all
users with security
administration rights set to
System Administration.
Double Width Block Select this option to spread the l List Block
block over two of the three l Chart Block
columns on the Classic l Content Block
Dashboard.
When users click Modify Dashboard on the Classic Dashboard tab, the newly created block is displayed
in Available Content.
1. Create an ASP page to display the content for the Classic Dashboard and save it in the Custom
Pages folder.
If you create an ASP page that uses the GetPage() method to display content, and you want to
suppress the tab group, pass the none parameter to the GetPage method.
From Sage CRM version 7.2b and later, all ASP pages must use the AddContent(Content) and
The example above contains a JavaScript function called callPage. The ASP page name (tesp.asp) is
passed as a parameter to the function and it builds the path including the correct session and context
information that allows the ASP page to use CRM blocks.
When users click Modify Dashboard within the Classic Dashboard tab, the newly created block is
displayed in Available Content.
When users click Modify Dashboard on the Classic Dashboard tab, the newly created block is displayed
in Available Content.
Field Description
Dashboard Level To display a block in the list of Available Content on the dashboard, select one of the
following options:
For an introduction to classic and interactive dashboards, see the User Help.
1. Create an ASP page to display the content for the Interactive Dashboard and save it in the Custom
Pages folder.
If you create an ASP page that uses the GetPage() method to display content, and you want to
suppress the tab group, pass the none parameter to the GetPage() method.
In Sage CRM version 7.2b or later, all ASP pages must use the AddContent(Content) and GetPage
() methods to build the HTML for the page. This is to ensure the correct rendering of the page
structure and links including the left hand main menu, horizontal tabs and top content.
Response.Write(CRM.GetPage("none"));
Company Context
http://[servername]/sdata/[installname]j/layout/-/$service/lp_
getContentBlockContent;jsessionid=F39FFB48CF51B873489DE9BF1ABDF0E5?id
=10651&SID=191832624935287&contextEntityId=5&contextRecordId=28
Key Variables
l ID. Specifies the unique ID of a block (custom_screenobjects).
l SID. Specifies session ID. Used by SOAP Web services/ASP/.NET APIs.
l contextEntityId. Specifies the unique ID of a table (custom_tables).
l contextRecordId. Specifies the unique ID of a record in the context table.
3. Log on to Sage CRM as a system administrator.
4. Go to <My Profile> | Administration | Customization | <Entity> | Blocks.
A list of existing blocks for the entity opens.
5. Click New and then use the following options:
l Block Name. Enter a name for your block.
l Block Type. Choose Content Block.
6. Click Save.
7. Click the new block and then from Interactive/Classic Dashboard Level choose
Available in Dashboards.
8. Add the following code into Contents, and then click Save:
<script>
window.attachEvent("onload",callPage("test.asp"))
function callPage(strPageName)
{
var SID = "";
var strPath = document.URL;
var arrayApp = strPath.split("eware.dll");
var arrayFullKeys = strPath.split("?");
var arrayKeys = arrayFullKeys[1].split("&");
for(var i=0;i<arrayKeys.length;i++)
{
var arrayValue = arrayKeys[i].split("=");
if (arrayValue[0].toLowerCase()== "sid")
{
SID = arrayValue[1];
}
}
var strNewPath = arrayApp[0] + "CustomPages/" + strPageName
This example contains a JavaScript function called callPage. The ASP page name (tesp.asp) is
passed as a parameter to the function and it builds the path including the correct session and context
information that allows the ASP page to use CRM blocks.
When users click New Gadget:Create Gadget within the Interactive Dashboard tab and select the Web
Site gadget, the newly created block is displayed in Available Content.
l scrmGetSageCRMOwner method
l scrmRegisterEvent method
l scrmPublishEvent method
l scrmGetGadgetProperty method
l scrmSetGadgetProperty method
l scrmSaveGadgetProperties method
scrmGetSageCRMOwner method
Finds the web site gadget that owns the current page.
Parameters
Example
gadget = parent.scrmGetSageCrmOwner(window.frameElement.id);
scrmRegisterEvent method
Registers event classes the gadget posts and/or listens to.
Parameters
l gadget. Gadget that publishes/receives event; Must not be null. May be obtained by calling
scrmGetSageCRMOwner method method.
l entityId. ID (custom_tables.bord_tableid) of entity that gadget publishes or may listen to. May be
null.
l fieldType. Type of field the gadget publishes/may listen to. May be null.
l fieldName. Name of field the gadget publishes/may listen to. Must not be null or empty.
l direction. Either PUBLISH (when gadget publishes information), LISTEN (when gadget responds
for events in other gadgets), or BOTH. Must not be null or empty.
Example
gadget = parent.scrmGetSageCrmOwner(window.frameElement.id);
parent.scrmRegisterEvent(gadget, "Test Field", "5", null, "BOTH");
Parameters
Example
gadget = parent.scrmGetSageCrmOwner(window.frameElement.id);
parent.scrmRegisterEvent(gadget, "Test Field", "5", null, "BOTH");
message = '{"entityRecordId":"' + document.forms[0].elements
["companyId"].value + '"}';
parent.scrmPublishEvent(gadget, "Test Field", message);
scrmGetGadgetProperty method
Gets gadget properties.
Parameters
Example
gadget = parent.scrmGetSageCrmOwner(window.frameElement.id);
propValue = parent.scrmGetGadgetProperty(gadget,document.forms[0].elements
["propertyName"].value);
scrmSetGadgetProperty method
Sets gadget properties so they can be saved.
Parameters
Example
gadget = parent.scrmGetSageCrmOwner(window.frameElement.id);
parent.scrmSetGadgetProperty(gadget, document.forms[0].elements
["propertyName"].value,
document.forms[0].elements["propertyValue"].value);
parent.scrmSaveGadgetProperties(gadget);
scrmSaveGadgetProperties method
Saves gadget properties on the server so they can be used again.
Parameters
Example
gadget = parent.scrmGetSageCrmOwner(window.frameElement.id);
parent.scrmSetGadgetProperty(gadget, document.forms[0].elements
["propertyName"].value,
document.forms[0].elements["propertyValue"].value);
parent.scrmSaveGadgetProperties(gadget);
</div>
</form>
l Administration menu
l Main menu
l Individual Administration work areas
l Some User (Main Menu) work areas
For more information on System Menus, see the System Administrator Help.
To customize tab groups for system menus:
To view the tab group, create a new main menu button and link it to an ASP page that calls the tab group.
When the user clicks the new menu button, the tabs in the new tab group are displayed.
For more information on customizing tabs, see the System Administrator Help.
The sample ASP page below sets the tab to display the invoice list for the current company. The ASP page
calls a previously created Invoice List. For more information on creating lists, see Creating a list.
<!-- #include file = "sagecrm.js" -->
<%
var ThisCompany;
var Invoices;
// Call the list block that you previously created for invoices.
Invoices = CRM.GetBlock("Invoice_List");
Invoices.Title = "3rd Party Invoice History";
To view the new tab, find a relevant entity record and click the new tab. For example, find a company and
click the Invoices tab.
If you want to restrict access to several tabs, avoid using the syntax user_userid=<User ID>, because
the database is queried separately for each restricted tab.
Rather, use one of the following:
Syntax Description
U:<User IDs> Makes the tab accessible to the specified users only.
Example
U:4,5
This example makes the tab accessible to the users whose IDs are 4
and 5.
C:<Channel IDs> Makes the tab accessible to the specified teams only.
Example
C:4,5
This example makes the tab accessible to the teams whose channel
IDs are 4 and 5.
T:<Territory IDs> Makes the tab accessible to the specified territories only.
Example
T:-2147483640
This example makes the tab accessible to the territory whose ID is -
2147483640.
Tab properties
Field Description
Caption Enter the tab name you want to appear on the Sage CRM user interface.
Action Select a tab action to display various Sage CRM screens. For more information,
see Tab actions.
Custom File Enter the name of the custom ASP file you want to use. This field only shows up
when in Action you select customfile.
The ASP file you specify must be stored in the following folder:
<Sage CRM Installation Folder>\<Install Name>\WWWRoot\CustomPages
If the target ASP file is stored in the root of that folder, you only need to enter the file
name, for example, MyCustomFile.asp.
If the target ASP file is stored in a subfolder, enter the subfolder name followed by
the file name, for example, MyAspFiles\MyCustomFile.asp.
Block Name Enter the name of the block you want to run.
This field only shows up when in Action you select runblock.
SQL Enter an SQL statement to restrict access to the tab to specific users, teams, or
territories. For more information, see Restricting access to a tab.
Bitmap Specify the graphic file you want to use. For example, when you're creating a menu
button linked to a custom page.
To include your custom graphic file in the list, copy it to the
the folder that stores graphic files for the current theme in Sage CRM.
When the current theme is Contemporary, graphic files are stored in the following
default folder:
l On a 32-bit (x86) system:
%ProgramFiles%\CRM\CRM\WWWRoot\Themes\Img\Ergonomic\Icons
l On a 64-bit (x64) system:
%ProgramFiles
(x86)%\CRM\CRM\WWWRoot\Themes\Img\Ergonomic\Icons
New Window Select if you want to open the custom URL in a new or current window.
(only available
when Action is l Yes. Opens the screen in a new window.
set to customurl. l No. Opens the screen in the current window.
Tab actions
When you create a new tab, you can specify the tab action. Each action displays different Sage CRM
screens including typical search screens and custom screens created using ASP pages. For information
about system actions that are available if you don't have the Extensibility Module, see the System
Administrator Help.
3. In Sage CRM, open the ASP page and then click the Help button.
The online help opens in a new window and displays the new help page.
Due to a limitation of this method, the new help page can't be included in the Sage CRM Help Table
of Contents, Index, or Search.
We recommend that you create backup copies of your custom help pages and store them in a safe place.
Any changes you make to help files in the Sage CRM installation folder may be overwritten when you
upgrade Sage CRM to a new version or install a Sage CRM patch.
You can create new database connections and external table connections. A database connection is the
registration of another database to which the Sage CRM server can connect directly or indirectly. You can
select from predefined database types. When you've made the database connection, you can create a new
table connection by referencing the new database connection or an existing database connection. You need
the Extensibility Module in order to create these connections. Also, the database with which the connection
is made must have a field that can uniquely identify the table, and there must be a matching field with this
value on the related table in Sage CRM.
The following columns are automatically included in the new table. If you entered a value in Company Id
Field, Person Id Field, or User Id Field, the corresponding ID field is created in the table.
When Sage CRM connects to the database, it appears in <My Profile> | Administration | Advanced
Customization | Tables And Databases.
l Improved database concurrency. The scripts are decoupled from the tables on which they are
acting.
l Easier debugging. The ErrorStr statement can be included to display diagnostic and handle
error messages. If an unhandled script error occurs, the system displays the script name, line
number, and the error message.
l Smoother upgrade process. Before performing an upgrade, you have to disable all SQL triggers
and then re-enable them afterwards. This is not the case with table- and entity-level scripts.
In this section:
l Table-level scripts
l Detached table-level scripts
l Entity-level scripts
l Creating a script
l Viewing script logs
l Disabling table-level scripts
Table-level scripts
Table-level scripts are executed when a record is inserted, updated, or deleted on a specified table. Table-
level scripts enable you to reference CRM objects and access external applications, such as Microsoft
Excel. For example, you could use a table-level script to write transaction logs of sensitive information to
specific columns of a text file.
Entity-level scripts
Entity-level scripts and entity-level with rollback scripts are executed when an entity is inserted, updated, or
deleted.
l Use entity-level scripts when an action is dependent on the whole entity. For example, you want to do
something when a whole Company is inserted, not just when a record is added to the Company
table.
l Use entity-level with rollback scripts when you want to stop an action if a script error occurs.
You can use entity-level scripts on the following entities: Company, Person, Email, and Address. The scripts
are invoked from the following standard Sage CRM screens when you click the final Save.
Creating a script
1. Log on to Sage CRM as a system administrator.
2. Go to <My Profile> | Administration | Customization | <Entity> | TableScripts.
3. Click New.
4. Complete the following options and click Save:
l Name. Enter a descriptive name with which you want to identify the script in the Sage
CRM user interface.
l Windows User as Domain\User (Optional). Enter the Windows user account under which
you want to run the script. Use the format domain\user name. If you leave this option blank,
the script is run under the current user account.
l User Password. Enter the password that matches the user account specified in
Windows User as Domain\User (Optional).
l Script Type. Select the type of your script.
l View. Only use this option when creating entity-level scripts. Enter the view from which fields
are available in the script. This must be relevant to the current entity. If you leave this option
blank, the default view for that entity is used.
l Order. Specify the order of scripts if there's more than one script for a table.
l Logging Level. Select the logging level to use when a user clicks Show Log:
l Off. Disables logging.
l Low. Writes low-level diagnostic information in the log table.
l Medium. Writes medium-level diagnostic information in the log table.
l High. Writes high-level diagnostic information in the log table.
l On error, only display the default error message. Select this check box to hide error
details from users. You can enter an alternative error message in Default Error Message. If
you select this check box but don't enter a default error message, no errors are shown to the
user.
l On error, retry the script after delay. Select this check box to re-run the script after a
defined amount of time when an error occurs. The script is automatically re-run until it
completes without errors. This is useful for situations where an external resource is
temporarily available. Every time the script is re-run, the amount of time until Sage CRM
retries the script is increased.
l Table level script. Use this text box to enter your table- or entity-level script. Depending on
the type of script you want to run, enter your script in the appropriate section. That is,
You can enable a disabled script at any time by clearing the Disabled check box.
Now, when you open a Company record in Sage CRM and click the Invoices tab, a list of invoices for the
Company record is displayed.
// Return the value of the field used as the hyperlink to this page.
ThisInvoice = Request.QueryString("InvoiceID");
// Create the block object from the screen block created in CRM.
InvoiceDetailBlock = CRM.GetBlock('Invoice_Detail');
// Pass the record object to the Screen block for execution later.
InvoiceDetailBlock.ArgObj = Record;
Container = CRM.GetBlock("container");
To see the results, open a Company record in Sage CRM, and click the Invoices tab. A list of invoices for
the Company record is displayed. The fields that are configured as links are formatted as hypertext.
To open the summary screen for the invoice, click an invoice number.
To return to the list, click Continue.
The steps in this example are applicable to Company, Person, Case, Lead, and Opportunity entities.
This example creates an ASP page to display a single record in the new table if it doesn't already exist.
4. Create a record for the installed base record and specify which record to display. See if the record
already exists. If it doesn't, create a new record.
record = CRM.FindRecord("InstallBase","companyid="+CompanyId);
if (record.eof)
{ r
ecord = CRM.CreateRecord("InstallBase");
record("CompanyId") = CompanyId;
InstallBase.Title = "New Install Base Details"; }
This allows the user to add or edit installed base details for each customer by clicking on the Installed
Base tab for a Company. The first time the tab is selected, a record is added for the Company.
Thereafter, when the tab is selected, the record is shown for editing.
// If the record does not exist then create one and set the company ID.
record = CRM.CreateRecord("InstallBase");
record("Inst_CompanyId") = CompanyId;
InstallBase.Title = "New Install Base Details";
}
else
{
InstallBase.Title = "Edit Install Base Details";
if (CRM.Mode <= 1)
{
CRM.Mode = 1;
}
%>
This example creates ASP pages to display multiple records in the new table for each customer. It creates
two custom pages; one to view a list of records and another to jump to individual records.
1. Create a custom page whose name matches the name specified in the tab group for Company. For a
sample Entry Group ASP page, see Create an ASP page to display a single record .
2. Include statements in the main block of the ASP page to perform the following tasks.
l Retrieve the identifying value for the current Company and assign it to a variable.
CompanyId = CRM.GetContextInfo("Company","Comp_CompanyId");
l Create a block for the Installed Base List and assign it to a variable. The list name is the name of
the list created in Step 3: Create a List object for installed base.
InstallBase = CRM.GetBlock("installbaselist");
l Write the list to the screen by executing the List block, telling it to show records for this company
only.
CRM.AddContent(InstallBase.Execute("Inst_
CompanyId="+ThisCompany));
l Add a New button to the screen to allow new records to be added. This calls another ASP page.
CRM.AddContent(CRM.Button("New","new.gif",CRM.Url
("InstallBaseEdit.asp")));
Response.Write(CRM.GetPage());
3. Create another custom page to jump to view/edit/delete individual records. The page name is the
name of the page specified in Custom Action File in Step 3: Create a List object for installed base.
4. Include statements in the main block of the ASP page to perform the following tasks:
l Retrieve the ID value of the record that's viewed from the Query string.
ThisInstallBase = Request.QueryString("Inst_InstallBaseId");
l Create a block for the Installed Base screen and assign it to a variable.
InstallBaseItem = CRM.GetBlock("InstallBaseDetailsBox");
l Turn on the Delete button on the block to allow existing records to be deleted.
DisplayButton(Button_Delete) = true;
l Check if this is an existing record or if a new record must be created. Create the Record object if
required. If it's a new record, the exact Company ID must be set and it must go straight into edit
mode.
if (!Defined(ThisInstallBase)) {
CompanyId = CRM.GetContextInfo("Company","Comp_CompanyId");
InstallBaseRecord = CRM.CreateRecord("InstallBase");
InstallBaseRecord("Inst_CompanyId") = CompanyId;
}
if (CRM.Mode <= Edit) {
CRM.Mode = Edit;
}
else {
InstallBaseRecord = CRM.FindRecord("InstallBase","Inst_
InstallBaseId="+ThisInstallBase);
}
5. Display the block, passing in the Record object. Note that the edit/delete/add functionality is handled
by the block internally.
// Add the New button to allow user to add new records for this company.
CRM.AddContent(CRM.Button("New","new.gif",CRM.Url
("InstallBaseEdit.asp")));
Response.Write(CRM.GetPage());
%>
To see the results, open a Company, and click the Installed Base tab. A list of installed base records for the
Company is displayed. The fields that are configured as links are formatted as hypertext.
l To edit or delete the summary screen for the record, click Record.
l To add new records from the list screen, click New.
The Company ID on the Installed Base table is an integer value. To display the Company name (rather than
the ID) in a report, set the Entry Type of the company ID field to Search Select, using the Company entity.
For more information about creating views, report categories, and reports, see the System Administrator
Help.
You can create a view that links the Installed Base table with another table so that more fields are available
on the report. For example, the Company table.
function UpdateRecord()
{
var sType = Comp_Type;
var sOldType = _HIDDENComp_Type;
if ((sType != null) && (sType.toLowerCase() == 'customer') &&
(sOldType != null) && (sOldType.toLowerCase() == 'prospect'))
2. Click Save.
2. Click Save.
Now when you create a new case for a Company but don't assign the case to a user, the case is
automatically assigned to the company account manager when you save it.
3. Click Save.
Create a new case and note the user to whom it's assigned. Log on as that user and open the
Calendar/Tasks list. The new communication is listed.
3. Click Save.
Open a Company Summary, change the Status to Archive, and click the Opportunities tab.
The stage of every Opportunity related to the Company is set to Sale Closed.
Open a Person record that has an associated Lead and then delete the Person record. The warning
message is displayed.
1. Download the Advanced Customization Wizard .zip file from the Sage CRM Partner Community.
Make sure you download the wizard for your version of Sage CRM.
You can search for and download the Advanced Customization Wizard (formerly known as the Main
Entity Wizard) on the Sage CRM Partner Community.
2. To access the Partner Community, you must be either a Sage CRM Business Partner or member of
the Sage CRM Developer Program. For more information on how to join, see Join the Sage CRM
Developer Program.
3. In Sage CRM, install and start the Advanced Customization Wizard:
a. Log on to Sage CRM as a system administrator.
b. Go to <My Profile> | Administration | Customization | Component Manager.
c. Under Add Component, specify the Advanced Customization Wizard .zip file you
downloaded in step 1 of this procedure.
d. Click Upload new component.
e. Under Available Components, click to select Advanced Customization Wizard, and then
click Install Component.
a. After its installation, the Advanced Customization Wizard remains listed under Available
Components. This allows you to use the wizard to create custom entities in the future.
4. On the Component Parameters, Step 1 of 2 screen, specify parameters for the entity being created.
For more information about these parameters, see Entity parameters.
Optionally, you can click Preview Install to view the configured entity parameters and export them to
a Comma-delimited values (.csv) file.
5. When you are finished, click Install Component and wait until entity creation completes.
In this step, the following screen elements are created:
l Name and status fields
l Search, entry, summary, and top content screens
l A grid for the new entity
l A tab group with a tab that contains a custom summary screen
Other screen elements depend on how you configured the entity parameters in step 3 of this
procedure.
6. When prompted, click Continue to finalize entity creation.
Entity Name Enter the name for the new custom entity you want to create.
This name identifies the following:
Entity Column Prefix Enter the four letter prefix you want to add to the names of columns in the
entity table.
Do not include an underscore. The prefix must follow the applicable identifier
rules configured on the database server.
Tag with Component Allows you to script out and further customize new entities. The value in this
Name text box has the following format:
<EntityName>_Component
A new component with this name is added to Existing Components.
When creating a new custom entity, you can select this component and click
Preview Script to view the changes involved in creating the entity.
You can set this component as the currently recording component and further
customize the entity. For example, you can script out the entire customization.
For more information, see Step 2: Generate script files.
Add to My CRM When selected, creates a custom list and a custom tab for the My CRM work
area. Displays a list of new entity records associated with a user.
Add to Find When selected, makes the custom entity available for search in Sage CRM.
Selecting this check box creates a custom search entry screen and a
corresponding search results list.
Add to Team CRM When selected, creates a custom list, an ASP page that displays the list, and a
custom tab for the Team CRM work area. Displays a list of all new entity
records associated with a team.
Has Companies When selected, creates a company tab and adds a corresponding custom
company list to the tab group.
This enables you to view a list of associated companies for all new entity
records, and link existing companies to the new entity using a Link button.
To set up deduplication for companies in this scenario, see Enabling
deduplication for a custom entity.
Has Accounts When selected, creates an account tab and adds a corresponding custom
account list to the tab group.
This enables you to view a list of associated accounts for all new entity
records, and link existing accounts to the new entity using a Link button.
This check box is only available if Integration is set up.
Owned by Companies When selected, adds a custom tab to the Company tab group. This custom
tab displays a list of associated new entity records for a company.
Allow Web Service When selected, enables the new entity for Web Services. For more
Access information, see Using Web Services API.
Has People When selected, creates a people tab and adds a corresponding custom
people list to the tab group.
This enables you to view a list of all associated people for all new entity
records, and link existing people to the new entity using a Link button.
To set up deduplication for people in this scenario, see Enabling deduplication
for a custom entity.
Owned by People When selected, adds a custom tab to the People tab group.
This custom tab displays a list of associated new entity records for a person.
Allow Read-only SData When selected, enables the new entity for SData. For more information, see
Access Using SData API.
Has Opportunities When selected, creates an opportunities tab and adds a corresponding
custom opportunities list to the tab group.
This allows you to view all the associated opportunities for all new entity
records.
Has Leads When selected, creates a lead tab and adds a corresponding custom leads list
to the tab group.
This allows you to view all the associated leads for all new entity records.
Owned by Leads When selected, adds a custom tab to the Leads tab group.
This custom tab displays a list of associated new entity records for a lead.
Has Cases When selected, creates a cases tab and adds a corresponding custom cases
list to the tab group.
This allows you to view associated cases for all new entity records.
Owned by Cases When selected, adds a custom tab to the Cases tab group.
This custom tab displays a list of associated new entity records for a case.
Has Communications When selected, creates a communications tab and adds a corresponding
custom communications list to the tab group.
This allows you to view associated communications for all entity records.
Select this check box to perform mail merges from the context of the newly
created entity.
Has Library When selected, creates a library tab and adds a corresponding custom library
list to the tab group.
This enables you to view all associated library entries for all new entity
records.
Select this option to perform mail merges from the context of the newly
created entity.
Owned by Orders When selected, adds a custom tab to the Orders tab group.
This custom tab displays a list of associated new entity records for an order.
Owned by Quotes When selected, adds a custom tab to the Quotes tab group.
This custom tab displays a list of all the associated new entity records for a
quote.
Workflow When selected, creates a workflow for the custom entity and enables default
workflow rules for the new entity.
Has Workflow Progress When selected, creates a progress table for the custom entity table and allows
you to add progress notes for custom entity records.
Deduplication When selected, creates a deduplication screen for the new entity so you can
set deduplication rules in Sage CRM.
To set up a deduplication screen for a new entity that has People or has
Companies, see Enabling deduplication for a custom entity.
For Dot Net When selected, creates an entity for which you can write a .NET module
instead of using ASP pages. The entity is created with metadata in the usual
way but as ASP pages are not created, you must use the .NET DLL to
customize the entity.
Owned by Accounts When selected, adds a custom tab to the Account tab group.
This custom tab displays a list of associated new entity records for an account.
This check box is only available if Integration is set up.
Owned by When selected, adds a custom tab to the Opportunities tab group. This
Opportunities custom tab displays a list of associated new entity records for an opportunity.
l ASP files
l Metadata
ASP files
The Advanced Customization Wizard generates custom ASP files for the custom entity depending on the
component parameters you configure for the entity.
These ASP files are stored in one of the following locations:
l On a 32-bit (x86) system:
%ProgramFiles%\Sage\CRM\<InstallName>\WWWRoot\CustomPages\<EntityName>
l On a 64-bit (x64) system:
%ProgramFiles(x86)%\Sage\CRM\<InstallName>\WWWRoot\CustomPages\<EntityName>
Metadata
The Main Entity Wizard generates metadata for the new main entity depending on the component
parameters you configure for the entity. You can view the metadata in Enterprise Manager (for example, in
the Custom_Tables table) and in Sage CRM (<My Profile> | Administration | Customization |
<Entity>).
Metadata Description
<EntityName>SearchBox The entry screen used for search selects and finds
on new entities.
<EntityName>Grid The grid used for search selects and finds on new
entity records.
l To enable deduplication if the entity has Companies, open the <EntityName>Company.asp file and
change the action from 140 to 1200.
l To enable deduplication if the entity has Persons, open the <EntityName>Person.asp file and
change the action from 141 to 1201.
From
CRM.URL(141)+"&Key-1="+iKey_
CustomEntity+"&PrevCustomURL="+List.prevURL+"&E=Accounts", 'Person',
'insert'));
to
CRM.URL(1201)+"&Key-1="+iKey_
CustomEntity+"&PrevCustomURL="+List.prevURL+"&E=Accounts", 'Person',
'insert'));
l <EntityName>.gif
l small_<EntityName>.gif
When the current theme in Sage CRM is Contemporary, the default locations of these files are as follows:
l On a 32-bit (x86) system:
%ProgramFiles%\Sage\CRM\CRM\WWWRoot\Themes\Img\Ergonomic\Icons
%ProgramFiles%\Sage\CRM\CRM\WWWRoot\Themes\Img\Ergonomic\Icons\Summary
l On a 64-bit (x64) system:
%ProgramFiles(x86)%\Sage\CRM\CRM\WWWRoot\Themes\Img\Ergonomic\Icons
%ProgramFiles(x86)%\Sage\CRM\CRM\WWWRoot\Themes\Img\Ergonomic\Icons\Summary
To change the default logos for an entity, create your custom .gif logo files, name them according to the
patterns above, and then copy your files to the appropriate locations to overwrite the original logo files stored
there.
Table Unique ID
Project proj_projectid
Cases case_caseid
7. Click Save.
The new view is listed in Source View on the Report Options, Step 1 of 2 page when you create a new
report.
In Sage CRM, you can implement graphics by using ASP pages. Graphics can be generated dynamically
within Sage CRM. A graphic can be data aware and representative of data stored at the time it's generated.
You can customize a graphic to vary depending on the user that displays it. Graphics can be generated with
just a few commands, or customized at length.
For more information about the methods you can use to work with graphics in Sage CRM, see
CRMGraphicBlock methods.
l JPEG. Default format for graphics and charts. 16 million colors (24 bit).
High level of compression (small file size). Does not support animation and transparency.
l GIF. 256 colors (8 bit). High level of compression (small file size). Supports animation and
transparency.
l BMP. Various color depths. No compression (large file size).
The characteristics of these formats can affect the image quality of your graphic or chart. If you don't require
animation and transparency, use JPEG rather than GIF, as JPEG allows your image to contain a much
greater color depth.
Fusion charts are rendered as JPEG in ASP and .NET, and they are rendered as Flash in the Classic and
Interactive Dashboard.
To save graphics as JPEG or GIF, you can use the SaveAsGifs and SaveAsJPG(text) methods exposed by
the CRMGraphicBlock object.
For example:
var graphic;
graphic =CRM.GetBlock('graphic');
graphic.SaveAsGifs=true;
Example 2
Effect('Merge','c:\\Person.ico,50,50');
l Dithering. You can apply a dithering mode to an image to help improve its appearance, especially
where color is limited. The available modes are:
l Burkes
l FloydSteinberg
l JaJuNi
l Sierra
l SteveArche
l Stucki
The following example shows how to apply a dithering mode to an image:
Effect('Dither','FloydSteinberg');
l Zooming. You can magnify an image using the Zoom parameter and a percentage of zoom
required. By default, the area to be zoomed is the center of the image.
Example:
Effect('Zoom','200');
l Transparency. Available only in GIF images. You can enable transparency to make any whiteness
in an image become transparent.
The following example shows how to enable transparency:
Effect('Transparency','true');
Setting a color
Use the following syntax to set the color:
Pen('Color','<ColorName>');
Examples
Pen('Style','Dot');
Pen('Style','Solid');
Pen('Style','Clear');
Specifying a color
Use the following syntax to specify the color with which you want to fill a shape:
Brush('Color','<ColorName>');
Loading an image
Use the following syntax to load an image and use it in all painting effects:
Brush('Load','<PathToImage>');
Where <PathToImage> is the full path to the image file you want to use. You can specify one of the
following file types: .ico, .emf/..wmf, .bmp, .gif, or .jpg.
Example
Brush('Load','c:\\winnt\\winnt.bmp');
Where <Left>, <Top>, <Right>, and <Bottom> define the rectangle area to be filled in.
Example
Brush('Fill','0,0,100,100');
l Bdiagonal
l Clear
l Cross
l DiagCross
l Fdiagonal
l Horizontal
l Solid
l Vertical
Example
Brush('Style','DiagCross');
Selecting a font
Use the following syntax to select a font:
Font('Name','<FontName>');
Where <FontName> is the name of the font installed on the Sage CRM server.
Example
Font('Name','Times New Roman');
Where <ColorName> is the name of the font color you want to use.
Example
Font('Color','Blue');
l Underline. Toggles between underlined and normal font. This parameter can take one of the
following values:
l True. Underlines the current font.
l False. Specifies to use normal font.
l Italic. Toggles between italic and normal font. This parameter can take one of the following values:
l True. Italicizes the current font.
l False. Specifies to use normal font.
l Strikeout. Toggles between striked out and normal font. This parameter can take one of the
following values:
l True. Adds a line through the middle of the current font.
l False. Specifies to use normal font.
Examples
Font('Underline','True');
Font('Italic','False');
Font('Strikeout','False');
l Add. Adds the next frame in a series. If no frames have been added previously, adds the first frame.
l Delay. Specifies delay for the animation. If this parameter is left blank, the default delay is used.
l Loops. Loops an animation a specified number of times or indefinitely. By default, an animation is
shown one time. To repeat an animation indefinitely, set this parameter to 0.
Examples
Animation('Add','50');
Animation('Add','');
Animation('Delay','50');
Animation('Loop','0');
To view the results, go to an Opportunity record and click the new tab you created.
For the complete ASP page code sample, see Code sample: Adding a pipeline.
6. Save your ASP file to the CustomPages folder in the Sage CRM installation directory.
The default locations of the CustomPages folder are as follows:
l On a 32-bit (x86) system:
%ProgramFiles%\Sage\CRM\CRM\WWWRoot
l On a 64-bit (x64) system:
%ProgramFiles(x86)%\Sage\CRM\CRM\WWWRoot
// The summary allows the addition of any desired text in HTML format for
the selected pipe section.
// This example shows a simple hard-coded value.
pipe.Pipe_Summary='<table><td class=TableHead>Qualified(70)</td></table>';
CRM.AddContent(pipe.Execute());
Response.Write(CRM.GetPage());
%>
Implementing animation
This sample code implements animation.
<!-- #include file ="sagecrm.js"-->
<%
var progress=70;
var anim=CRM.GetBlock('graphic');
with(anim)
{
ImageWidth=130;
ImageHeight=20;
Pen('Color','Black');
MoveTo(0,0);
LineTo(99,0);
LineTo(99,19);
LineTo(0,19);
LineTo(0,0);
Rectangle(0,0,100,20);
Pen('Color','Blue');
for (y=1;y<=progress;y++)
{MoveTo(y,1);
LineTo(y,19);
TextOutCenter(101,0,129,19,y+'%',false,false);
Animation('add','10')}
}
var container=CRM.GetBlock('container');
with(container)
{AddBlock(anim);
DisplayButton(Button_Default)=false;}
CRM.AddContent(container.Execute());
Response.Write(CRM.GetPage());
%>
This section provides code samples illustrating how to create charts to graphically represent information in
Sage CRM. Sage CRM includes a FusionCharts component that allows you to create animated and
interactive widgets providing various information. You can also create organization charts.
l ChartTimeoutSeconds. Specifies the timeout (in seconds) before the conversion of FusionCharts
to images starts. The resulting images are displayed on the Sage CRM user interface.
l ChartUseFlash. Specifies how to display FusionCharts: as Flash or as static images.
l ReportsShowTextErrorInsteadOfImage. Allows errors. Use this parameter in combination with
the ChartUseFlash parameter. No data and no flash to be displayed as customized images in
accordance with the file names below:
l Theme/Images/no_adobeflash.jpg
l Theme/Images/no_adobeflash-US.jpg
l Theme/Images/ no_data.jpg
l Theme/Images/ no_data.jpg-US.jpg
l ChartOverruledWidthID. Specifies overrule width for Interactive Dashboard chart width.
l ChartOverruledHeightID. Specifies overrule height for Interactive Dashboard chart height.
l ChartOverruledWidthCD. Specifies overrule width for Classic Dashboard chart width.
l ChartOverruledHeightCD. Specifies overrule height for Classic Dashboard chart height.
});
})
</script>
To view the created widget, go to an Opportunity record and open the Summary tab.
<script>
// Define variable to store data returned by Ajax requests
var myResults = {};
crm.ready(function () {
// Function script
var strScriptPath = crm.installUrl() +
"FusionCharts/FusionCharts.js";
$.getScript(strScriptPath, function (data, textStatus, jqxhr) {
// Get Opportunities and Cases for each Company and store them in
variables
// Make sure to properly sequence Ajax requests, because chart can
only be added after requests return data
var companyID = crm.getArg("key1");
var strOppoWhereClause = "oppo_primarycompanyid eq " + companyID;
var strCaseWhereClause = "case_primarycompanyid eq " + companyID;
var successCase = function (crmRecord) {
myResults.CaseCount = crmRecord.totalResults;
myChart.render("chartContainer");
</script>
To view the created widget, go to a Company record and open the Summary tab.
The following example shows how to display this chart on a new tab for each Company:
// Add the chart title. If you omit the Title parameter, no title is
added.
org.OrgTree("Title","My chart");
// Define the style of connectors in the chart. You can use Arrow,
Ray, or Line.
org.OrgTree("LineStyle","Ray");
// Define the style of boxes in the chart. You can use Square or
Round.
org.OrgTree("BoxStyle","Round");
// Optionally, define the height of each box in the chart. To use the
default height, omit this line.
// org.OrgTree("BoxHeight","50");
// Optionally, define the width of each box in the chart. To use the
default width, omit this line.
// org.OrgTree("BoxWidth","100");
You can use the Related Entities feature to set up and view complex relationship types between
primary entities. For more information on related entities, see the System Administrator Help.
2. Save the ASP file in the CustomPages folder in the Sage CRM installation directory.
The default locations of the CustomPages folder are:
l On a 32-bit (x86) system:
%ProgramFiles%\Sage\CRM\CRM\WWWRoot\CustomPages
l On a 64-bit (x64) system:
%ProgramFiles(x86)%\Sage\CRM\CRM\WWWRoot\CustomPages
3. Create a new tab and link it to your ASP file:
a. Log on to Sage CRM as a system administrator.
b. Go to <My Profile> | Administration | Customization.
c. Click Company, and then click Tabs.
d. In the Tab Group Name column, click Company.
e. Under Properties, use the following options:
l Caption. Enter the new tab name.
l Action. Select customfile.
l Custom File. Enter the name of the custom ASP file you created in step 1 of this
procedure.
4. Click Update, and then click Save.
You can view the created organization chart on the new tab you created for each Company record.
l Programmatically create, read, update, and delete entity records in the Sage CRM database. For
example, Companies, People, Opportunities, Cases, Quotes, and Orders.
l Integrate third-party applications used within your organization with Sage CRM.
Sage CRM Web Services provide a standardized method for integrating web-based applications using the
following components via an Internet protocol backbone:
Web Services allow organizations to exchange data without in-depth knowledge of the IT systems behind
the firewall. Web Services don't provide users with a GUI, which is the case with traditional client/server
models. Instead, Web Services share business logic, data, and processes through a programmatic interface
across a network. Developers can add the Web Services to a GUI, such as a web page or an executable
program, to provide users with the required functionality. The technology makes it possible for applications
The SOAP Web Services API is only available in certain editions of Sage CRM. For more information, see
the Sage CRM Editions Comparison Guide.
Sage CRM Web Services support all development environments that are compatible with SOAP 1.1. These
environments include:
l Only one Web Services user can be logged on to Sage CRM at any given time. If a user tries to log on
as another application, the user is prompted to log out first. However, it's possible to log on to the
desktop or from a device with the same ID while a Web Service application is running.
l Web Services cannot work with Sage CRM fields to which the user account does not have access.
For more information about using field security, see the System Administrator Help.
Option Description
Maximum number Specifies the maximum number of records that Web Services return in a batch in
of records to return response to a query. When this option is set to 0, all records matching the query
are returned in a single batch.
This option is used in conjunction with the query and queryrecord methods. When
a batch is returned, you're prompted to call the next batch, until all records
matching the query are returned.
Maximum size of Specifies the maximum size of request (in characters) that can be sent to Web
request Services.
Make WSDL Specifies whether the Sage CRM Web Services WSDL file is accessible.
available to all Possible values:
When configuring and testing Web Services, we recommend that you set this
option to Yes. When you're done, set this option to No for better security.
To view the WSDL file, in your web browser, enter the URL in the following format:
http://<ComputerName>/<InstallName>/eware.dll/webservices/webservice.wsdl.
Enable Web Specifies whether Web Services are enabled in Sage CRM.
Services Possible values:
To enable or disable Web Services for an individual entity, log on to Sage CRM as
a system administrator, go to <My Profile> | Administration | Customization |
<Entity> | External Access, and then use the Allow Web Service Access
option.
Dropdown fields as Specifies whether to display selection fields and their enumeration values in the
strings in WSDL file WSDL file.
Possible values:
When this option is set to No, a selection field (comm_status in this case)
displayed in the WSDL file looks similar to the following:
<simpleType name="comm_status">
<restriction base="xsd:string">
<enumeration value="Cancelled"/>
<enumeration value="Complete"/>
<enumeration value="Pending"/>
<enumeration value="In Progress"/>
</restriction>
</simpleType>
When this option is set to Yes, information about selection fields is excluded from
the WSDL file.
Send and return all Specifies the format in which Sage CRM Web Services send and receive times
dates and times in and dates.
universal time Possible values:
This option is important when migrating users from different time zones.
Accept web Specifies the unique IP address from which Web Services accept requests. You
request from IP can only specify one IP address in this option.
address Leave this option blank to allow requests from all IP addresses.
Force web service Specifies how to handle the client's attempt to log back on to Web Services when
logon the connection is unexpectedly interrupted.
Possible values:
l f. Free text.
l c. Comment.
l productid
l uomid
l quantity
l quotedprice
l f. Free text.
l c. Comment.
l description
l quantity
l quotedprice
l f. Free text.
l c. Comment.
l description
l linetype
l orderquoteid
The following fields are populated automatically by Sage CRM and cannot be changed by the user:
l quotedpricetotal
l listprice
l discount
l discountsum
If you're using Microsoft Visual Studio to create a client application, your Visual Studio project should contain
a web reference to the WSDL file. When you add the reference in Visual Studio, the main pane lists the
methods available from the Web Services.
Method Description
logoff Logs off the client from the server and terminates the session.
query Executes a query on a specified object based on a where clause, and returns a
record or record set that satisfies the query.
Returns results in batches. You specify batch size in the Maximum number of
records to return option. For more information, see Configuring Web Services.
Each batch is accompanied by a flag called More. If More is True, there are more
records waiting on the server for that query. Call Next to get the next batch of
data. If anything other than Next is called, the query is closed.
queryidnodate Returns an object of type aisid. For more information, see Abstract objects.
To return specific objects, use a where clause.
getmetadata Returns a list of Sage CRM field types to provide metadata about the requested
table.
getdropdownvalues Returns a list of drop-down fields for a specified table, and the values that Sage
CRM expects for each field.
addresource Adds a user as a resource. This user is not a fully enabled user. This method
facilitates data migration.
altercolumnwidth Resizes a column width to ensure compatibility with third-party databases, for
example, ACT!.
l newproduct
l uomfamily
l productfamily
l pricing
l pricinglist
queryrecord Executes a query on a specified object based on a where clause, and returns a
record or record set that satisfies the query.
This method has a different signature than the query method and uses the lists of
fields in the crmrecord type.
nextqueryrecord Returns the next batch of records matching a queryrecord. Each batch is
accompanied by a flag called More. While More is True, you can continue to call
Next until all batches are returned. More is then False.
getallmetadata Returns a list of fields associated with all tables and some type information.
l Abstract objects
l Standard objects
Abstract objects
Object Description
Standard objects
Object Description
Company l comp_employees
l comp_indcode
l comp_mailrestriction
l comp_revenue
l comp_sector
l comp_source
l comp_status
l comp_territory
l comp_type
Person l pers_gender
l pers_salutation
l pers_source
l pers_status
l pers_territory
l pers_titlecode
Lead l lead_decisiontimeframe
l lead_priority
l lead_rating
l lead_source
l lead_stage
l lead_status
Communication l comm_action
l comm_hasattachments
l comm_notifydelta
l comm_outcome
l comm_priority
l comm_status
l comm_type
Opportunity l oppo_priority
l oppo_product
l oppo_scenario
l oppo_source
l oppo_stage
l oppo_status
l oppo_type
Case l case_foundver
l case_problemtype
l case_productarea
l case_solutiontype
l case_source
l case_stage
l case_status
l case_targetver
Address l addr_country
l prod_uomcategory
Product l addr_country
l prod_uomcategory
By default, the WSDL file displays selection fields and their possible values. To hide selection fields in the
WSDL file, use the Dropdown fields as strings in WSDL file option in the Web Services configuration
settings. For more information , see Configuring Web Services.
The next example displays the comp_sector selection field values in a comboSector combo-box, where the
web service object is named oWebService.
LoadDropDowns("company", "sector", comboSector, oWebService);
Logon request
This C# example logs on to Sage CRM.
// An Instance of the web service.
private static WebService binding = null;
// Persistent for the duration of the program, maintain the logon results
private static logonresult SID = null;
private static void LogonToCRMSystem() {
try {
HttpWebRequest request =
(HttpWebRequest)WebRequest.Create("http://cloud.sagecrm.com/
myCustomerID/eware.dll/webservices/CRMwebservice.wsdl");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
binding = new WebService(); SID = binding.logon("admin", "");
binding.SessionHeaderValue = new SessionHeader();
//Persistent SID
binding.SessionHeaderValue.sessionId = SID.sessionid;
return true;
}
catch (SoapException e) {
Write(e.Message);
Authentication response
The following is a sample authentication response indicating that authentication against the endpoint was a
success. The response format is JSON.
{
"installName":"<myCustomerID>",
"wsdlUrl":"https://cloud.na.sagecrm.com/<CustomerID>/eware.dll/
webservices/CRMwebservice.wsdl",
"wsUrlConnection":"https://cloud.na.sagecrm.com/<CustomerID>/
eware.dll/webservices/",
"web2LeadUrl":"https://cloud.na.sagecrm.com/<CustomerID>/eware.dll/
SubmitLead",
"sDataUrl":"https://cloud.na.sagecrm.com/sdata/<CustomerID>j/
sagecrm/",
"edition":"professional",
"domain":"cloud.na.sagecrm.com",
"userId":1,
"teamId":1,
"found":true,
"userAuthenticated":true,
"userWebServicesEnabled":true,
"userDisabled":false
}
Logoff request
This C# example logs off from Sage CRM.
Delete request
This C# example deletes a company whose ID is 1.
ewarebase[] idList = new ewarebase[1];
crmid aCompanyId = new crmid();
aCompanyId.crmid1 = 1; //1 is id of company to delete
idList[0] = aCompanyId;
deleteresult aResult = binding.delete("company", idList);
if (aResult.deletesuccess == true) {
Write("Number deleted successfully : " + aResult.numberdeleted);
}
Update request
This C# example changes the name of the company whose ID is 66.
private static void UpdateACompany()
{
String idString = "66";
String newName = "newName";
//can update a number of companies
ewarebase[] companyList = new ewarebase[1];
company aCompany = new company();
aCompany.companyid = Convert.ToInt16(idString);
aCompany.companyidSpecified = true;
aCompany.name = newName;
companyList[0] = aCompany;
updateresult aresult = binding.update("company", companyList);
if(aresult.updatesuccess == true)
{}
else
{}
}
Query request
This example queries a company record whose ID is 66.
company aCompany = (company) binding.queryentity(66, "company").records;
C# code samples
Sage CRM is supplied with a number of Microsoft Visual Studio 2005 C# solutions that contain code
samples you can use when developing Web Services applications for Sage CRM.
On a Sage CRM server, you can find these C# solutions in the following location:
<Sage CRM installation folder>\WWWRoot\Examples\WebServices
By default, Sage CRM is installed to one of the following locations:
l On a 32-bit (x86) system: %ProgramFiles%\Sage\CRM\CRM
l On a 64-bit (x64) system: %ProgramFiles(x86)%\Sage\CRM\CRM
In the specified location, you will find the Sage CRM Web Services Sample Code.zip file that includes the
following folders:
l CRM Add Resource. Contains code that adds a resource (user) to Sage CRM through Web
Services. The sample code lets you enter a first name and a last name for the resource. It creates a
record in the User table.
To run sample code, enter your Sage CRM user name and password, and click Log On. When you're
finished working with code samples, click Log Off. Make sure that you specify the correct reference to the
WSDL file. For more information, see Using the WSDL file.
About SData
SData is a standard that can be used to read, write, update, and delete data between applications. It also
provides more complex functions such as synchronization of data, security, discoverability of services, single
sign-on, error handling, and paging and batching of information for increased performance. SData enables
desktop, server, and web-based Sage applications to communicate with each other, third-party
applications, and the web.
In Sage CRM, SData can only be used to read data by using the ATOM feed technology. SData is built on
top of common industry standards including HTTP, XML, REST, and Atom/RSS. Any Sage CRM user can
use SData. It doesn’t use up a user license so a user can be logged into Sage CRM and access data
through a third-party, external application.
Each entity, custom table, and user view in Sage CRM can be exposed for read-only SData access. An
XSD schema definition is available to provide information about which entities are exposed.
An SData request triggers an XML-based response. The response can include a single record or a
collection of records. If the response size for an SData request exceeds 100 records, it defaults to 100
records. If a user tries to access SData from an external system and defines a page count of 200 records in
the URL, the payload returns the records in blocks of 100 records per page. The same applies if a user
defines a URL with no pagination.
For more information about SData, please refer to the following:
Apache Tomcat is a servlet container developed by the Apache Software Foundation (ASF). Tomcat
implements the Java Servlet and JavaServer Pages (JSP) specifications from Sun Microsystems, and
provides a pure Java HTTP web server environment for Java code to run. Every request issued for the
SData Provider is redirected to the Tomcat Server.
If you're working with Sage CRM and encounter a problem that requires a web server reset, you might need
to reset both Microsoft Web Server (IIS) and Apache Tomcat. For more information, see the System
Administrator Guide or Help.
l Entities
l Custom tables
Entities
To enable or disable read-only SData access to an entity:
By default, SData access is enabled for all primary and secondary entities.
Changing SData settings for an entity doesn't affect SData settings specified for the user views of the entity.
You can also enable or disable read-only SData access when creating a new custom entity by using the
Advanced Customization Wizard. For more information, see Creating a custom entity.
Custom tables
To enable or disable read-only SData when creating a new custom table:
Changing SData settings for an entity doesn't affect SData settings specified for the user views of the entity.
http://SageCrmServer/sdata/crmj/
sagecrm/-/company?where=
comp_companyid eq '43'
http://SageCrmServer/sdata/crmj/
sagecrm/-/company(comp_companyid eq
'43')
http://CRMserver/sdata/crmj/
sagecrm/-/company?where=comp_
companyid eq '43'&include=Person
You can also use fast SData requests for AJAX in Custom Content and OnChange scripts, for example:
<script>
function GetKeyValue(querystringname)
{
var strPath = window.location.search.substring(1);
var arrayKeys = strPath.split("&");
for (var i=0;i<arrayKeys.length;i++)
{
var arrayValue = arrayKeys[i].split("=");
if (arrayValue[0].toLowerCase()== querystringname.toLowerCase())
{
return arrayValue[1];
SData authentication
All SData requests must include authentication data (user name and password) in their headers. SData
access is subject to the same territory model as Sage CRM users. Profile security (CRUD rights per entity)
and access rights depend on the user type, for example, administrator or non-administrator.
Make sure that you use Base64 encoding to encrypt the user name and password supplied in the HTTP
request header with X-Sage-Authorization line included, as shown below:
request.Headers.Add("X-Sage-Authorization", "Basic "+
Convert.ToBase64String(Encoding.ASCII.GetBytes(this.userName + ":" +
this.password)));
For better security, we recommend that you send authentication requests via HTTPS.
To create DLLs for Sage CRM, you can use Microsoft Visual Studio or any other tool supporting Microsoft
.NET Framework 2.0.
We recommend that you install the Sage CRM .NET SDK (Software Development Kit) for your version of
Sage CRM. For instructions, see Installing Sage CRM .NET SDK.
Please consider the following before you start using the Sage CRM .NET API:
l References to Sage CRM .NET API from within ASP.NET are not supported. For this reason,
you cannot create ASP.NET pages and call them from within Sage CRM.
l Supported programming languages. With Sage CRM .NET API, you can use any programming
language that conforms to Microsoft .NET Framework 2.0, including C#, J#, and VB.NET.
After setting a system parameter, you need to refresh system parameter metadata: go to <My
Profile> | Administration | System, and then click Refresh Metadata.
Computer on which you plan to develop custom l Sage CRM 7.2 or later with a valid developer
.NET DLLs. license key
Note: The Sage CRM version must be the
same as the one installed on the target Sage
CRM server.
l Sage CRM .NET SDK
l Microsoft Visual Studio 2012 or 2010
Note: Other development tools may also be
suitable, such as Visual Studio 2015 or Visual
Studio Express. In this case, you need to
manually copy the templates, snippets, and
example projects to the correct folder after
installing the Sage CRM .NET SDK.
For more information, see Manually copying
C# project templates, snippets, and example
projects.
l Microsoft .NET Framework 2.0
Target Sage CRM server on which you plan to l Sage CRM 7.2 or later with a valid license key
deploy your .NET DLLs. l Microsoft .NET Framework 2.0
1. Download the Sage CRM .NET SDK installation package for your version of Sage CRM.
You can download the .NET SDK installation packages on the Sage CRM Partner Community.
2. Extract the contents of the downloaded .zip file to a temporary folder on your local disk drive.
3. Run the crmsdk.exe file and complete the wizard that starts.
The Sage .NET SDK registers a number of DLLs that provide the runtime environment in the Global
Assembly Cache (GAC).
On a computer where the .NET SDK is installed, these DLLs are located in the following folder:
In order you could work with the Sage CRM .NET SDK, the following DLL assemblies must be installed to
the GAC (Global Assembly Cache) folder and properly registered:
In .NET Framework 2.0, the default location of the Global Assembly Cache is %windir%\assembly.
However, in some situations the automatic installation and registration of the above assemblies may fail. In
this case, you may receive an error message when you install the .NET SDK or create a new C# project
from a template supplied with the .NET SDK. The error you receive may be similar to the following: "This
template attempted to load an untrusted component".
To fix this issue, manually install and register the assemblies, as follows:
1. On the computer where the Sage CRM .NET SDK is installed, open Visual Studio Command
Prompt.
2. Change directory to the folder where the above-listed DLL assemblies are stored. By default, this is
one of the following:
l On a 32-bit (x86) system: %ProgramFiles%\Sage\CRM\CrmDotNet\<Sage CRM version
number>
l On a 64-bit (x64) system: %ProgramFiles(x86)%\Sage\CRM\CrmDotNet\<Sage
CRM version number>
Example: cd %ProgramFiles(x86)%\Sage\CRM\CrmDotNet\7.3
3. Use the gacutil /if command to force the installation of each .NET SDK assembly.
Example: gacutil /if sagecrmnet.dll
4. Use the regasm command to register each installed .NET SDK assembly.
Example: regasm sagecrmnet.dll
In some situations, the Sage CRM C# project templates, snippets, and example projects supplied with the
Sage CRM .NET SDK may be missing from Microsoft Visual Studio when you create a new C# project. This
is because the template files Sage CRM 7 Basic Template.zip and Sage CRM 7 Entity Template.zip
may be copied to the incorrect folder on your computer when you install the Sage CRM .NET SDK.
For example, if you are using Visual Studio 2008, these .zip files may be erroneously copied to the following
incorrect folder:
%UserProfile%\Documents\Visual Studio 2012\Templates\ProjectTemplates\Visual C#
1. On a computer where the Sage CRM .NET SDK is installed, open one of the following folders:
l On a 32-bit (x86) system:
%ProgramFiles%\Sage\<InstallName>\CRMDotNet\Class Library Documentation
l On a 64-bit (x64) system:
%ProgramFiles(x86)%\Sage\<InstallName>\CRMDotNet\Class Library Documentation
The default install name is CRM.
2. Double-click the SageCRMNet.chm file.
Alternatively, you can view the descriptions of namespaces, classes, methods, and properties in the Object
Browser in Microsoft Visual Studio on a computer where Sage CRM .NET SDK is installed.
Provided C# templates
Sage CRM .NET SDK installs the following C# templates for creating custom .NET DLLs:
l Basic template. Allows you to customize standard Sage CRM interfaces and functionality.
l Entity template. Allows 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 the following
folder:
Basic template
The basic template allows you to customize standard Sage CRM interfaces and functionality. This template
creates the following .cs files:
l Base.cs
l CustomPage.cs
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:
l AppFactory. This class is required for every .NET DLL created for Sage CRM. It contains the
methods that are called from within Sage CRM.
l 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
{
In this code:
l 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.
l 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.
l 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.
Entity template
The 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 do this first in the Sage CRM front end or through the Advanced
Customization Wizard.
When you use the entity template to create a new C# project in Microsoft Visual Studio, the CRM .NET
Entity Wizard starts. In this wizard, complete the following options, and then click GO!:
l CrmBase.cs. Contains methods to call each .cs file created by the template.
l EntityDataPage.cs. Defines the screen that allows a user to view an entity in Sage CRM. The
IdField and EntityName values are the ones you entered when you created your C# project from the
entity template. AddEntryGroup specifies the entry group that's displayed. Its default value is
EntityNameNewEntry. You can change this to whatever you've named your block in Sage CRM.
l EntityDataPageDelete.cs, EntityDataPageEdit.cs, and EntityDataPageNew.cs. Are similar to
EntityDataPage.cs. They Create an instance of the specialized web class. The IdField, EntityName,
and AddEntryGroup values are the ones you entered when you created your C# project from the
entity template.
l EntityListPage.cs. Displays a list of entities in Sage CRM. It creates an instance of a specialized
web class ListPage. The EntityName value 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 and FilterByContextId allow the list to be filtered dynamically, in this case by user ID.
l EntitySearchPage.cs. Displays the search or find screen for the entity. It creates an instance of the
specialized web class SearchPage.
l CompanySummary. Illustrates how to insert, update, or delete data on the Company Summary
screen by using the generalized web class. This project includes class definitions that handle the
display and layout of the Company Summary screen and retrieve data using both the FindRecord
and QuerySelect mechanisms.
l CompoundEntryScreen. Illustrates how to build a compound screen by using a generalized web
class. With this example project, you can see how to enter Company, Person, and Opportunity
records within a single screen, insert records into the database, and maintain relationships between
these records.
l QuickLook. Illustrates how to use multiple blocks on the Company Quick Look screen and how to
manage the paging and display of rows. The project uses a generalized web class to modify the
interface.
l RelatedEntities. Illustrates how to use the .NET API to work with user and administration screens.
This example project contains the source code for the Related Entities feature used withing the main
Sage CRM entities. The project uses the generalized web class and specialized classes such as
DataPageEdit to modify the interface.
The code in the project controls how a relationship is defined and how that relationship is maintained
l Visual C#\My Code Snippets\Sage CRM 7 DOTNET Snippets. Holds snippets that illustrate
how to use the generalized web class and the specialist classes available through the .NET API. You
can use these snippets to define screens, lists, and buttons, save and retrieve data, and establish
context.
l Visual C#\My Code Snippets\Sage CRM 7 Web Service Snippets. Holds snippets that illustrate
how to use the SOAP-based Web Services API. You can use these snippets to initiate and terminate
sessions and perform create, read, update, and delete operations.
l Visual Web Developer\My HTML Snippets\SageCRM. Holds snippets that illustrate how to
create ASP pages by using the Sage CRM COM API.
l Visual Web Developer\My JScript Snippets\SageCRM. Holds JavaScript code snippets that
cover the full range of screen and list creation within extensions for Sage CRM built using classic
ASP pages.
For more information about code snippets, see the following article posted on the Sage CRM Partner
Community:
https://community.sagecrm.com/partner_community/b/hints_tips_and_tricks/archive/2013/10/15/sage-
crm-7-2-sdk-installer-now-available.aspx
Do not remove the DotNetWrapper and SageCRMNet assemblies, because they are required for Sage
CRM.
You can copy your .NET .dll file to the CustomDotNet folder manually or specify that folder as the build
location in the Microsoft Visual Studio project properties.
The CustomDotNet folder contains the RelatedEntities.dll file. Do not move, delete, or rename this file, as
the Relationships feature of Sage CRM depends on this DLL.
Where:
l <DllFileName>. Is the name of the .NET .dll file you want to reference. Make sure the .dll file is
stored in the required location on the Sage CRM server. For more information, see Storage location for
Example:
string sUrl = UrlDotNet("MyDllFile.dll", "RunViewOpportunity");
AddUrlButton("Cancel", "Cancel.gif", sUrl);
Alternatively, you can use the Dispatch.Redirect method within another .NET DLL, for example:
Dispatch.Redirect(UrlDotNet(“MyDllFile.dll”, “RunDataPage”));
l The.NET API redirect occurs only when the .NET .dll is finished processing the code, and it must
provide the HTTP response before being unloaded from memory.
l Use the Dispatch.Redirect method inside BuildContents only and return it after the redirect is set.
Otherwise, system performance could be seriously impacted.
l Only use one redirect in the code, and set the URL in any previous branches in the code.
The .dll file you reference must be stored in the Storage location for custom .NET DLLs.
Never use the above debugging methods in a production environment. These methods are only intended for
development or testing environment.
Issue Resolution
Visual Studio doesn’t stop at your break point. Make sure that the corresponding .pdb file for your
custom .NET DLL is copied to the Storage location
for custom .NET DLLs on the Sage CRM server.
.NET Framework needs the .pdf file to find the
source code.
The managed option is not available on the Reset IIS and run any .NET API code at least
Inetinfo.exe process. once.
The process isn't created in Component Services. Verify that you have the correct version of DLLs
and have set the correct password.
An error message similar to "Interface not Unregister your .NET DLL, and then register it
supported" appears in Sage CRM when you again.
invoke your .NET code. The COM+ debugging method only works with
Sage CRM version 7.2 and later. This error
message may appear if you work with an earlier
version of Sage CRM.
The debugging method you use stops working Make sure that you use the correct password on
after a few days. the Component Service.
The application process is created correctly on Make sure you enable integrated Windows
Component Services, but an error message similar authentication in IIS.
to "Interface not supported" appears in Sage CRM. For more information, see the MSDN article titled
"Error: Debugging Failed Because Integrated
Windows Authentication Is Not Enabled" for your
version of Visual Studio.
Complete the next steps to create a screen that displays Company, Person, and Opportunity entry blocks,
allowing three records to be entered and saved at the same time. The user is then redirected to the
summary screen of the newly created company.
Now follow the instructions in Step 2: Add code to get, display, and format blocks to add your code in the
braces.
In the CustomPage.cs file, add the following code between the braces in the BuildContents() method:
}
2. Add code to get the blocks or screens that allow the user to enter data, display and format them, and
save the data entered by the user:
public override void BuildContents()
{
AddContent(HTML.Form());
EntryGroup screenCompanyBoxLong = new EntryGroup("CompanyBoxLong");
screenCompanyBoxLong.Title = Metadata.GetTranslation("tabnames",
"company");
EntryGroup screenPersonBoxLong = new EntryGroup("PersonBoxLong");
screenPersonBoxLong.Title = Metadata.GetTranslation("tabnames",
"person");
EntryGroup screenOppo = new EntryGroup("OpportunityDetailBox");
screenOppo.Title = Metadata.GetTranslation("tabnames",
"opportunity");
}
3. Get the current mode stored in the HiddenMode hidden field (that is, Save or Edit):
string hMode = Dispatch.EitherField("HiddenMode");
if (hMode == "Save")
{
// Add code for saving. For details, see .
}
else
{
// Add code for displaying the forms. For details, see .
}
Now follow the instructions in Step 3: Add code to the if and else statements.
The code you write in this step should go between the braces in the if and else statements, as follows:
string hMode = Dispatch.EitherField("HiddenMode");
if (hMode == "Save")
{
// Add code to save the data entered by user. See step 1 below.
}
else
{
// Add code to display the Sage CRM forms. See step 2 below.
}
The redirect only occurs after the .NET dll is finished processing the code, and needs to provide the HTTP
response before being unloaded from memory. Only use the Dispatch.Redirect() method inside the
BuildContents() method and return it after the redirect is set, otherwise system performance could be
seriously impacted. Use only one Dispatch.Redirect() method in your code, and the set the URL in any other
places in the code.
Now add buttons as described in Step 4: Add Save, Cancel, and Help buttons.
After the code you added to the else statement in Step 3: Add code to the if and else statements, add the
below code to display Save, Cancel, and Help buttons.
Open the Base.cs file that was automatically created when you selected the Basic template, and then
rename the RunMyCustomPage() method in the file to RunEntryScreen().
As a result, the code in the Base.cs file should look similar to the following:
using System;
using System.Collections.Generic;
using System.Text;
using Sage.CRM.WebObject;
namespace CompoundEntryScreen
{
public static class AppFactory
{
public static void RunEntryScreen(ref Web AretVal)
{
AretVal = new EntryScreen();
}
}
}
Now follow the instructions in Step 6: Build your solution and copy compiled DLL.
The files, references, and stub code provided in a Sage CRM template provide a compilable application that
you can customize and extend.
l ASP objects
l Component Manager methods
AddressList object Provides access to the lists of recipients (To, Cc, and Bcc).
CRMBase object Sets up the context information for the current view and displays the tabs
for that view.
CRMContentBlock object Is a simple block that takes a text string and displays it on the page.
CRMFileBlock object Provides access to external files that are not part of the system.
CRMGraphicBlock object Use this block to display images through an ASP page.
CRMGridColBlock object Use this object to set the properties of an individual column within a list.
CRMMessageBlock object Use this object to send messages in SMS and email format.
CRMPipelineGraphicBlock Use this object to create cross-sectional diagrams that represent data from
object an ASP page or table.
CRMQuery object Use this object to enter and execute SQL statements against a known
system database.
CRMSelfService object Provides access to the CRM database and to many CRM object methods,
from outside the CRM application.
CRMTargetListField object Use this objects to define fields to be included in a target list.
CRMTargetLists object Use this object to create and save a target list in conjunction with the
CRMTargetListField object and CRMTargetListFields object.
Email object Use this object to customize scripts deployed by E-mail Management. The
Email object provides access to an email through its properties and
methods.
MailAddress object Use this object to customize scripts deployed by E-mail Management. The
MailAddress object provides access to an individual address from the
AddressList object.
MsgHandler object Use this object customize scripts deployed by E-mail Management. It
provides basic access to the Email object and functionality for the system.
l AddressList methods
l AddressList properties
AddressList methods
AddAddress(Address, Name). Adds an address to the list of recipients in an email.
AddAddress(Address, Name)
Parameters
Examples
AddressList properties
l Items. Returns email addresses and names in the form of a MailAddress object.
l Count. Returns the number of email addresses in the list.
Items
Returns email addresses and recipient names in the form of a MailAddress object.
Parameters
Examples
var emailAddress;
emailAddress = email.Recipients.Items(1).Address;
Returns the email address located at index position 1 in the To list and stores the address in the
emailAddress variable.
Count
Property value
Integer
Examples
if (email.Recipients.Count==1) {
// Insert code to perform action here.
}
Specifies to perform some action if the number of email addresses in the To list equals 1.
l Attachment methods
l Attachment properties
Attachment methods
l Save(Name, Path). Saves the attachment to a specified folder.
l SaveAs(Name, Path). Saves the attachment as a file with the specified name.
Save(Name, Path)
Parameters
l Name. Specifies the name of the file in which to save the attachment. The parameter is passed by
reference and may be returned with a different value than the value sent to it.
l Path. Specifies the full path to the folder in which to save the attachment.
Return value
Boolean:
Examples
AttItem.Save("MyAttachment.txt", "C:\Attachments");
Saves the attachment stored in the AttItem variable to the MyAttachment.txt file located in the Attachments
folder.
SaveAs(Name, Path)
l Name. Specifies the name of the file in which to save the attachment.
l Path. Specifies the full path to the location of the file.
Return value
Boolean:
Examples
AttItem.SaveAs("MyAttachment.txt", "C:\Attachments");
Saves the attachment stored in the AttItem variable to the MyAttachment.txt file located in the Attachments
folder.
Attachment properties
l Name. Gets or sets the file name of the attachment.
l Extension. Gets the file name extension of the attachment.
Name
Property value
String (read/write)
Examples
var newname;
newname = AttItem.Name + "MyAttachment" + AttItem.Extension;
Adds the string MyAttachment as a suffix to the original file name of the attachment stored in the AttItem
variable. Keeps the file name extension of the attachment. Stores the new file name of the attachment in the
newname variable.
Extension
String (read-only)
Examples
var newname;
newname = AttItem.Name + "MyAttachment" + AttItem.Extension;
Adds the string MyAttachment as a suffix to the original file name of the attachment stored in the AttItem
variable. Keeps the file name extension of the attachment. Stores the new file name of the attachment in the
newname variable.
l AttachmentList properties
AttachmentList properties
l Count. Returns the number of attachments.
l Items. Returns an attachment in the form of an Attachment object.
l LibraryPath. Specifies the path to the Sage CRM library.
Count
Property value
Integer (read-only)
Examples
Items
Property value
Examples
LibraryPath
Specifies the path to the Sage CRM library. This is the Library folder in the Sage CRM installation directory.
The default location of the Library folder is %ProgramFiles%\Sage\CRM\CRM\Library.
Property value
String
Examples
l CRM methods
l CRM properties
CRM methods
l AddContent(Content). Adds the value in its parameter to the page in memory and returns that value
when the GetPage() method is called.
l CreateQueryObj(SQL, Database). Creates a new query object from the system database or an
external database to which Sage CRM is connected.
l CreateRecord(TableName). Creates a new record object in a specified database table.
l FindRecord(TableName, QueryString). Finds and retrieves a record object from a specified
database table.
l GetBlock(BlockName). Retrieves a Sage CRM block.
l GetCustomEntityTopFrame(Entity). Retrieves the top content (the icon, caption, and description) for
a custom entity.
l GetPage(). Returns the page contents that have been previously added by the AddContent method.
l GetTrans(Family, Caption). Returns the translation for a caption in the specified caption family,
based on user's current language.
l RefreshMetaData(Family). Updates the Sage CRM internal cache with new information.
l SetContext(EntityName, EntityID). Updates the recent list for the specified custom entity.
AddContent(Content)
Adds the value in its parameter to the page in memory and returns that value when the GetPage() method is
called. You can use this value in scripts to pass something that is only available on the server side, such as
the current user's email address.
In Sage CRM version 7.2b and later, all ASP pages must use the AddContent() and GetPage() methods to
build the HTML for the page. This is required to ensure the correct rendering of the page structure and links,
including the left-hand main menu, horizontal tabs, and top content.
Examples
var MyList;
MyList = CRM.GetBlock('PersonGrid');
CRM.AddContent(MyList.Execute("pers_lastname like 'B%'"));
Response.Write(CRM.GetPage());
CRM.AddContent('<' + 'script>var defaultemailaddress=\'' + CRM.UserOption
('defaultemailaddress') + '\'<' + '/script>');
CreateQueryObj(SQL, Database)
Creates a new query object from the system database or an external database to which Sage CRM is
connected.
This method can return different data than the FindRecord(TableName, QueryString) method for the
following reasons.
The CreateQueryObject method creates a new connection, uses a transaction that is different from the one
used for update, and thus can only work with data that is actually in the database. The commit takes place
after table-level scripts are run.
The FindRecord(TableName, QueryString) method, however, uses the dispatch connection, so it's the
same transaction as the one used by the update. Therefore, this method can work with uncommitted data.
Parameters
Examples
var Query;
Query = CRM.CreateQueryObj("Select * from vcompany");
Query.SelectSql();
CRM.AddContent(Query.FieldValue("comp_name"));
while (!Query.eof)
{
CRM.AddContent(Query.FieldValue("comp_name") + '
');
Query.NextRecord();
}
Response.Write(CRM.GetPage());
Creates a query object from the company view by using the system database.
Creates a new record object in a specified database table. To save the record object, you must call the
SaveChanges() method. The SaveChanges() method is automatically called by the Execute(Arg) method
of most blocks when the mode is set to Save.
Parameters
TableName. Specifies the name of the table where the record is to be created. This can be the Sage CRM
system database or an external database to which Sage CRM is connected.
Examples
FindRecord(TableName, QueryString)
Parameters
l TableName. Specifies the database table from which you want to retrieve a record object.
l QueryString. Specifies the SQL WHERE clause that identifies the record object.
Example
var ThisPersonId;
var PersonBlock;
ThisPersonId = CRM.GetContextInfo('Person','Pers_PersonId');
ThisPersonRecord = CRM.FindRecord('Person','Pers_Personid='+ThisPersonId);
PersonBlock = CRM.GetBlock('PersonBoxLong');
CRM.AddContent(PersonBlock.Execute(ThisPersonRecord));
Response.Write(CRM.GetPage());
Retrieves a block. Use this method to call child blocks of the CRM object. For more information, see Blocks.
Parameters
BlockName. Specifies the name of the block, existing screen or list in Sage CRM to retrieve.
Examples
var Marquee;
Marquee = CRM.GetBlock("marquee");
Gets a Container, Search (CompanySearchBox), and List (CompanyGrid) block. Adds the search screen
and list to the container and displays the container. You can configure the Execute method to use the search
results as the argument for the list.
GetCustomEntityTopFrame(Entity)
Retrieves the top content (the icon, caption, and description) for a custom entity.
Parameters
Entity. Specifies the name of the entity for which to retrieve the top content.
Examples
CRM.GetCustomEntityTopFrame("Lease");
Retrieves the top content for the custom entity named Lease.
GetPage()
Returns the page contents that have been previously added by the AddContent method. The contents
are returned in the format specified by the current device.
Parameters
TabGroupName. Optional. Specifies the tab group name that includes the tabs to be passed to the method.
In this case, the method shows the passed tabs instead of the current default tabs.
Examples
GetTrans(Family, Caption)
Returns the translation for a caption in the specified caption family, based on user's current language.
Self-Service users can set the language using the VisitorInfo method, for example:
CRM.VisitorInfo("Visi_Language")='DE';
Parameters
l Family. Specifies the name of the caption family to which the caption belongs. To view available
caption families and caption types, go to <My Profile> | Administration | Customization |
Translations.
l Caption. Specifies the name of the caption.
Examples
CRM.AddContent(CRM.GetTrans('GenCaptions','Screen'));
Response.Write(CRM.GetPage());
Displays the word Screen in the user's current language, provided that the translation in that language has
already been added to Sage CRM translations.
Updates the Sage CRM internal cache with new information. For example. when the custom_captions table
was edited or new records were added.
Parameters
Examples
var NewCaption;
NewCaption = CRM.CreateRecord("Custom_Captions");
NewCaption.Capt_FamilyType = "Choices";
NewCaption.Capt_Family = "Comp_Status";
NewCaption.Capt_Code = "Open";
NewCaption.Capt_US = "Open";
NewCaption.SaveChanges();
CRM.RefreshMetaData("Comp_Status");
SetContext(EntityName, EntityID)
Parameters
Examples
CRM.SetContext(EntityName,Id);
CRM properties
Mode. Sets a mode for a block.
Mode
Sets a mode for a block. The values this property can take are defined in the include file.
Property values
Examples
Changes the mode to Save if an error has occurred. Also displays the error.
l CRMBase methods
l CRMBase properties
CRMBase methods
l Button. Returns the text, image, and link for a Sage CRM button.
l GetContextInfo(Entity, FieldName). Returns the named field from a table based on the current
context.
l GetTabs(TabGroup). Returns the specified group of tabs.
l Logon(LogonId, Password). Allows you to log on to Sage CRM from a command prompt.
l Url(Action). Transforms a URL to the format required by Sage CRM.
l ConvertValue(Avalue, AfromCurr, AToCurr). Converts a value from one currency to another.
Button
Returns the text, image, and link for a Sage CRM button. These buttons are typically the generic buttons
that appear on screens and containers. For example, you can use this method to add buttons that open web
sites or ASP pages.
Parameters
l Caption. Specifies the caption for the button. The caption is translated based on the user's
language, provided that a matching translation exists for the caption.
l ImageName. Specifies the image to display on the button. The image must be stored in the Img
folder located in the Sage CRM installation directory.
l URL. Specifies the URL to link the button to. This can be a web address or a custom page located in
the CustomPages folder in the Sage CRM installation directory.
l PermissionsEntity. Specifies the entity name. Allows you to add the button based on a users
security profile for an entity.
l PermissionsType. Specifies permissions to apply. This can be VIEW, EDIT, DELETE, or INSERT,
depending on the action the button performs. Allows you to add the button based on a users security
profile for an entity.
l Target. Sets the TARGET property of the button's anchor.
Displays a button named My button. This button contains an image stored in the MyImage.gif file and is
linked to the MyPage.asp file.
GetContextInfo(Entity, FieldName)
Returns the named field from a table based on the current context. Use this method to return the RecordID
for a table which you can use to build an SQL query. For example, to create charts.
Parameters
l Entity. Specifies the entity from which to return the field. This can be: Person, Company,
Opportunity, Lead, Case, Solution, Channels (teams), Campaigns, Waves, Wave Items,
SelectedUser (applicable when viewing the My CRM list), User (currently logged on user).
l FieldName. Specifies the name of the field to be returned.
Examples
GetContextInfo("case", "case_description");
Returns description for the case that the user is currently viewing.
ThisCompanyId = CRM.GetContextInfo('Company','Comp_CompanyId');
CaseListBlock = CRM.GetBlock('CaseList'); SearchSql = 'Case_
PrimaryCompanyId='+ThisCompanyId + " and Case_Status='In Progress' ";
CRM.AddContent(CaseListBlock.Execute(SearchSql)); Response.Write
(CRM.GetPage());
Displays cases that are currently in progress for the current company context.
This example obtains the unique company ID. Company ID is used in a SQL statement, which selects all
cases that match the company's ID and have an In Progress status.
The GetBlock(BlockName) method returns a CRMListBlock object of type CaseList, which is stored in the
CaseListBlock variable .
The SELECT statement used to extract the required cases is passed to the CaseListBlock's Execute
function. The populated CaseListBlock is then passed as an argument to the AddContent(Content) method
to store the page in memory.
Response.Write outputs the generated HTML to the screen.
Returns the specified group of tabs. You can use this method to specify a new tab group that you want
displayed from a menu option.
Only invoke this method if you are using an old include file (for example, CRM.js). Include this method at the
top of your ASP file and after the CRM.js include file. This method is not needed if you use the SAGECRM.js
or ACCPACCRM.js include file.
Parameters
Examples
Adds a new menu button that displays a new tab group. The button links to an ASP that includes the
GetTabs method.
<%= CRM.GetTabs() %>
Logon(LogonId, Password)
Parameters
Return value
Allows you to start using the Sage CRM object under a specified user account. Place this code in an external
JavaScript page. You can copy and paste your encrypted password from the system database. It is a good
practice to create a dedicated user account for external access to the system with limited access rights.
Url(Action)
Transforms a URL to the format required by Sage CRM. You can use the returned URL to create a link in
Sage CRM.
Parameters
Action. Specifies a URL, ASP file, or .NET DLL file and method. If it's an ASP file, custompages is
prepended and the CRM context information is appended. You can also pass in an action string. Anything
else returns the action untouched.
Examples
CRM.AddContent(CRM.Button("Chart","Cancel.gif",CRM.Url
("system/InvChart.asp")));
Response.Write(CRM.GetPage());
Creates a link that references the RunQuickLook base method of a .NET DLL(QuickLook.dll).
Parameters
Return value
String containing the converted value formatted to the number of decimals specified for the currency in the
AToCurr parameter.
Examples
var iValue;
var iFromCurr;
var iToCurr;
iValue = 50,000;
iFromCurr = 1; // Where 1 is the identifier of Euro.
iToCurr = 2; // Where 2 is the identifier of British Pound.
CRM.AddContent("British Pound: " + CRM.ConvertValue(iValue, iFromCurr,
iToCurr));
Response.Write(CRM.GetPage());
CRMBase properties
l FastLogon. Disables the loading of metadata cache when a user logs on externally.
l TargetLists. Retrieves a CRMTargetLists object.
FastLogon
Disables the loading of metadata cache when a user logs on externally. Use this property with the Logon
(LogonId, Password) method.
Property values
l 1(default). Off.
l 2. Low.
l 3. High.
Examples
Disables the loading of metadata cache and logs on the administrator account.
l CRMBlock methods
l CRMBlock properties
CRMBlock methods
l Execute(Arg). Executes the Sage CRM block and returns the display contents of the block.
l Validate(). Validates data entries.
Execute(Arg)
Executes the Sage CRM block and returns the display contents of the block.
Parameters
Arg (optional). Specifies any value that relates to the block type.
Example
Validate()
Validates data entries. For example, this method checks to see if a required field is filled in. This method is
normally used in if statements.
Examples
Validates the relevant fields and displays an error message if validation has failed.
ArgObj
Examples
SearchContainer = CRM.GetBlock('Container');
SearchBlock = CRM.GetBlock('PersonSearchBox');
SearchContainer.AddBlock(SearchBlock);
if (CRM.Mode == 2) {
resultsBlock = CRM.GetBlock('PersonGrid');
resultsBlock.ArgObj = SearchBlock;
SearchContainer.AddBlock(resultsBlock);}
CRM.AddContent(SearchContainer.Execute());
Response.Write(CRM.GetPage)
Passes the SearchBlock result as the argument to the list block and displays the relevant search or results
list.
CheckLocks
Specifies whether to check if a record is in use before allowing the record to be edited. If the record is in use,
displays an error message. Only applicable on EntryGroup or Container blocks.
Examples
Block = CRM.GetBlock("companyboxlong");
Block.CheckLocks = false;
DisplayForm
Property values
Examples
block = CRM.GetBlock("companyboxlong");
block.DisplayForm = true;
CRM.AddContent(block.execute());
Response.Write(CRM.GetPage());
Wraps the companyboxlong block in a form element, which means it follows the normal save/change steps
(such as performing validation tasks).
FormAction
Sets the action that the form takes. You can use this property only if the DisplayForm property is set to true.
By default, the form action is blank, which causes a submit to return to the same page.
Property parameters
None
Examples
block.FormAction = "mypage.asp";
Sets the block position in pixels or percent from the top of the screen. The value of this property determines
how far the block appears from the top of the screen.
Property parameters
None
Examples
Sets the block to be 150 pixels from the top of the screen.
Name
Property parameters
Name. String. Specifies the new name for the block instance.
Examples
var block=CRM.GetBlock("entry");
block.Name="My New Block";
CRM.AddContent(block.Name);
Response.Write(CRM.GetPage());
NewLine
Specifies whether the block appears on a new line. This property is only applicable to CRMEntryBlock
object or CRMEntryGroupBlock object in a container.
This is the same as selecting New Line in the Position property from <My Profile> | Administration |
Customization | <Entity> | Blocks.
Property values
ShowValidationErrors
Sets whether to display validation errors when a user incorrectly enters information in an entry box.
Property values
Examples
var MyBlock;
MyBlock = CRM.GetBlock("entrygroup");
MyBlock.ShowValidationErrors = false;
Title
Examples
Specifies the name of the view on which the list is based. Only use this property with CRMListBlock object.
Examples
Width
Examples
Mode
Sets a mode for the ASP page. This allows you to control what happens to certain blocks when they are
executed.
Property values
Constants are declared for these values in the Sage CRM include files.
Examples
If the CRM.Mode of the EntryGroup block is set to View (0), this example changes the mode to Edit (1) and
displays the block in that mode.
l CRMChartGraphicBlock methods
l CRMChartGraphicBlock properties
CRMChartGraphicBlock methods
l BackGradient(Visible, StartColor, EndColor). Applies a gradient to the background of a chart.
l ChartTitle(text). Sets a title for the chart.
l ManualChartEntry(Value, MakeNull=true/false). Creates a chart where the data is not contained in a
Sage CRM table.
l ShowLegend(true/false). Determines whether to show or hide the legend for the chart.
l Style(Stylename). Sets the style of the chart.
Parameters
Examples
ChartGraph.BackGradient(true,'Blue','White');
Sets a title for the chart. If no chart title is set, the title is removed allowing more room for the chart.
Parameters
Text. Sets a title for the chart. This parameter accepts a WideString value.
Examples
ChartGraph.ChartTitle('Case Priority');
ManualChartEntry(Value, MakeNull=true/false)
Creates a chart where the data is not contained in a Sage CRM table.
It enables data to be hardcoded into a chart without relying on it being in a table. The parameters passed
vary depending on the style of table in use (for example, bar).
Parameters
l Value. Sets a value for a chart entry. This parameter accepts a WideString value.
l MakeNull. Defines whether the corresponding chart entry is blank. Accepts one of the following
values:
l True
l False
Examples
ChartGraph.ManualChartEntry('10,Jan',false);
ChartGraph.ManualChartEntry('10,Feb',false);
ChartGraph.ManualChartEntry('+5,Feb',false);
ChartGraph.ManualChartEntry('20,Mar',false);
ChartGraph.ManualChartEntry('30,Apr',false);
ChartGraph.ManualChartEntry('-5,Apr',false)
ShowLegend(true/false)
Boolean. Sets whether or not to show the chart legend. Can take one of the following values:
Examples
ChartGraph.ShowLegend(true);
Style(Stylename)
Parameters
Stylename. Specifies the name of the chart style to be used. This parameter accepts one of the following
text values:
Examples
ChartGraph.Style('Pie');
CRMChartGraphicBlock properties
l LabelX. Sets the text label for the X-axis (horizontal) of a chart.
l LabelY. Sets the text label for the Y-axis (vertical) of a chart.
LabelX
Values
Text. Specifies the text label for the X-axis. This parameter accepts a WideString value.
Examples
ChartGraph.LabelX = 'Date';
LabelY
Values
Text. Specifies the text label for the Y-axis. This parameter accepts a WideString value.
Examples
SQLText=Text
Uses a SQL query to retrieve and assign values to the LabelX, LabelY, and XLProp=text parameters from
the specified database table. This only occurs if no values were set for the mentioned parameters.
SQL query goes through the database table and uses the first field values that satisfy the specified criteria as
values for the parameters.
for the chart if X,Y, or XL labels haven't been set. Sage CRM navigates through the fields in the table as
defined in the SQL query and uses the first fields it finds and is able to use.
Text. Specifies the SQL query to be used for retrieving and assigning values for the parameters. This must
be a WideString value.
Examples
XLProp=text
Values
Text. Specifies the field name that stores the text values to be displayed on the X-axis. Accepts a
WideString value.
Examples
ChartGraph.XLProp = 'Fld_Date';
Uses values stored in the Fld_Date field as values for the X-axis.
Xprop=text
Values
Example
ChartGraph.Xprop = 'Fld_Date';
Yprop=text
Values
ChartGraph.Yprop = 'Fld_Date';
l Change or Save. Displayed as Change when the screen is in View mode and Save when the
screen is Edit mode. This button is shown by default.
l Delete or Confirm Delete. Displayed as Delete when the screen is in View mode and Confirm
Delete when the screen is in Confirm Delete mode. This button is not shown by default.
l Continue or Cancel. Displayed as Continue when the screen is in View mode and Cancel when
the screen is in Edit or Confirm Delete mode. This button is not shown by default.
The Execute function on a block takes only one argument. When CRMContainerBlock is executed, it passes
its argument to all its item blocks as they are executed. If item blocks in a container block require different
arguments for their Execute functions, set the ArgObj property on each item block and don't pass any
argument to the container.
Syntax to create a container with two blocks:
// Create a container.
Container = CRM.GetBlock("container");
// Get two screens.
Screen1 = CRM.GetBlock("Screen1");
Screen2 = CRM.GetBlock("Screen2");
// Add the screens to the container block.
Container.AddBlock(Screen1);
Container.AddBlock(Screen2);
// Display the container block, which displays the two blocks it contains.
CRM.AddContent(Container.Execute());
Response.Write(CRM.GetPage());
l CRMContainerBlock methods
l CRMContainerBlock properties
l Code example: ShowWorkflowButtons property
l Code example: WorkflowTable and ShowNewWorkflowButtons properties
CRMContainerBlock methods
l AddBlock(Block). Adds a block to a container.
l AddButton(ButtonString). Adds a button to the Container block.
AddBlock(Block)
Parameters
Block. Specifies a reference to the block to be added. This can be any block previously retrieved by using
the GetBlock(BlockName) method.
Examples
MyContainer = CRM.GetBlock("container");
MyPerson = CRM.GetBlock("personboxlong");
MyCompany = CRM.GetBlock("companyboxlong");
MyContainer.AddBlock(MyPerson);
MyContainer.AddBlock(MyCompany);
CRM.AddContent(MyContainer.Execute());
Response.Write(CRM.GetPage());
AddButton(ButtonString)
Parameters
ButtonString. Specifies HTML code to render the button. This should be a link within a <table> tag in the
ASP page. This parameter accepts a string value.
Examples
R = CRM.FindRecord('Company','Comp_CompanyId=1');
Holder = CRM.GetBlock('companyboxlong');
Holder.AddButton(CRM.Button("Try This","new.gif",CRM.Url
("AnotherPage.asp")));
CRM.AddContent(Holder.Execute(R));
Response.Write(CRM.GetPage());
Parameters
BlockName. Specifies the name of the block to be deleted. This parameter accepts a string value.
Examples
MyC = CRM.GetBlock("CompanySummaryBlock");
userLevel = CRM.GetContextInfo("User","User_Per_Admin");
if (userLevel > 1)
{
MyC.DeleteBlock("AddressBoxShort");
}
CRM.AddContent(MyC.Execute());
Response.Write(CRM.GetPage());
GetBlock(BlockName)
Returns a pointer to the specified block object that exists within the container.
Parameters
BlockName. Specifies the name of the block to return. This parameter accepts a string value.
Examples
MyCustomContainer = CRM.GetBlock("MyCustomContainer");
R = CRM.FindRecord('Company','Comp_CompanyId=30');
MyE = MyCustomContainer.GetBlock("CompanyBoxShort");
CRM.AddContent(MyE.Execute(R));
Response.Write(CRM.GetPage());
Displays the CompanyBoxShort block in the MyCustomContainer container block. This container block has
been set up in the <My Profile> | Administration | Customization | Company | Blocks area of Sage
CRM.
ButtonAlignment
Values
Possible values of this property are defined in the SageCrmNoLang.js include file and by default are as
follows:
l 0. Bottom.
l 1. Left.
l 2. Right.
l 3. Top.
The values this parameter can take depend on the value set in the ButtonLocation parameter.
If the ButtonLocation parameter is set to Top or Bottom, the ButtonAlignment parameter can only be set to
Left (1) or Right (2).
If the ButtonLocation parameter is set to Left or Right, the ButtonAlignment parameter can only be set to
Top (3) or Bottom (0).
Example
Container = CRM.GetBlock("container");
Container.ButtonLocation = Top;
Container.ButtonAlignment = 1;
CRM.AddContent(Container.Execute());
Response.Write(CRM.GetPage());
ButtonImage
Specifies the image file that contains an icon to be displayed on the standard Change or Save button. Use
this property to override the default image file for the buttons.
The image file you specify must be stored in the following location:
<Sage CRM installation folder>\WWWRoot\Img\Buttons
If the image file you want to use is stored in a different location, specify the full path to the file.
Example
Container = CRM.GetBlock("container");
Container.DisplayButton(Button_Default) = true;
Container.ButtonTitle = "My Button Title";
CRM.AddContent(Container.Execute());
Response.Write(CRM.GetPage());
ButtonLocation
Values
Possible values of this property are defined in the SageCrmNoLang.js include file and by default are as
follows:
l Bottom
l Left
l Right (default)
l Top
If this property is set to Top or Bottom, the buttons are shown in a horizontal line. Otherwise, they are
shown in a vertical line.
Examples
Container = CRM.GetBlock('container');
Container.DisplayButton(Button_Delete)= true;
Container.DisplayButton(Button_Continue)=true;
Container.DisplayButton(Button_Default)=true;
Container.ButtonTitle="My Button Title";
Container.ButtonLocation = Top;
CRM.AddContent(Container.Execute());
Response.Write(CRM.GetPage());
Overrides the default text labels on the standard buttons, such as Change and Save (Button_Default).
Value
Example
Container = CRM.GetBlock("container");
Container.DisplayButton(Button_Default) = true;
Container.ButtonTitle = "My Button";
CRM.AddContent(Container.Execute());
Response.Write(CRM.GetPage());
DisplayButton
Parameters
l (Button_Default). Specifies whether to show or hide the Change and Save buttons. Can take one
of the following values:
l true. Shows the buttons.
l false. Hides the buttons.
l (Button_Delete). Specifies whether to show or hide the Delete button. Can take one of the
following values:
l true. Shows the button.
l false. Hides the button.
l (Button_Continue). Specifies whether to show or hide the Continue button. Can take one of the
following values:
l true. Shows the button.
l false. Hides the button.
Container = CRM.GetBlock("container");
Container.DisplayButton(Button_Delete) = true;
Container.DisplayButton(Button_Continue) = true;
Container.DisplayButton(Button_Default) = true;
CRM.AddContent(Container.Execute());
Response.Write(CRM.GetPage());
Workflow properties
Use Workflow properties to include the same button types in an ASP page for any table in the system
database, including new custom tables that you've added for a customer. The Container block has three
properties that enable Workflow functionality:
Use these properties on tables for which you've configured workflow rules and states and want to display
the rules and states as workflow buttons. For example, if you've enabled workflow on the Cases table in
CRM, a New button is displayed for every primary workflow rule in the Cases List. When you edit a case,
workflow buttons applicable to that case are displayed.
To use Workflow properties on a new custom CRM table, the table connection must have CRM required
fields: xxx_createdby, xxx_createddate, xxx_updatedby, xxx_updateddate, xxx_timestamp, and xxx_
deleted (where xxx is the prefix on all the fields in that table). The following conditions also apply:
l There must be a numeric field on the table to hold the workflow ID. This is typically called xxxx_
workflowid.
l When creating the table link, enter the name of your workflow ID field on the Table Details screen.
For more information, see Database.
l Configure the workflow rules, states, and tree for the table in <My Profile> | Administration |
Advanced Customization | Workflow. For more information, see the System Administrator Guide
or Help.
l Use the Custom File Name property. Typically this points to the edit.asp file page that displays the
entry group.
The .asp file specified in the Custom File Name property must:
l Use a Container block (such as container, list, or entry group).
l Set the Container Block WorkflowTable property to the table name.
WorkflowTable
Parameters
Example
Container = CRM.GetBlock('container');
Container.WorkflowTable = 'company';
ShowWorkflowButtons
Values
Examples
Record = CRM.FindRecord('MyTable','Table_Id=99');
EntryGroup = CRM.GetBlock('MyTableBlock');
EntryGroup.ShowWorkflowButtons = true;
CRM.AddContent(EntryGroup.Execute(Record));
Response.Write(CRM.GetPage());
ShowNewWorkflowButtons
Values
Example
List = CRM.GetBlock('MyTableList');
List.WorkflowTable = 'MyTable';
List.ShowNewWorkflowButtons = true;
CRM.AddContent(List.Execute(''));
Response.Write(CRM.GetPage());
l The custom file name in the List to jump to. In this case it shows the edit screen for one record in the
table and the workflow buttons for the current record.
l The custom file name in the Primary rule. In this case the page creates a new record in the workflow.
// Display the Continue button. This button takes the user back to the
list.
DisplayButton(Button_Continue) = true;
Title = "My Table Details";
}
// To show the button on the right, put the list into a container and add
the button to the container.
Holder = CRM.GetBlock("container");
CRMContentBlock properties
Contents. Sets the text string for the Content block.
Contents
Values
Examples
test = CRM.GetBlock('content');
test.contents = '<table> <td class=tablehead>My Details</td></table>'
CRM.AddContent(test.Execute());
Response.Write(CRM.GetPage());
l CRMEntryBlock methods
l CRMEntryBlock properties
CRMEntryBlock methods
RemoveLookup. Removes specified items from the lists.
RemoveLookup
Parameters
Examples
r = CRM.FindRecord('Company','Comp_companyid=30');
CompanyBlock = CRM.GetBlock('companyboxlong');
NewE = CompanyBlock.GetEntry('comp_type');
NewE.RemoveLookup("customer");
CRM.AddContent(CompanyBlock.Execute(r));
Response.Write(CRM.GetPage());
Removes the Customer list item from the Type list on the Company entry screen.
AllowBlank
Values
r = CRM.FindRecord('Company','Comp_companyid=44');
EG = CRM.GetBlock('companyboxlong');
NewE = EG.GetBlock('comp_revenue');
NewE.AllowBlank = false;
CRM.AddContent(EG.Execute(r));
Response.Write(CRM.GetPage());
Caption
Values
Examples
r = CRM.FindRecord('Company','Comp_companyid=30');
EG = CRM.GetBlock('companyboxlong');
NewE = EG.GetBlock('comp_revenue');
NewE.Caption = 'My new caption';
CRM.AddContent(EG.Execute(r));
Response.Write(CRM.GetPage());
CaptionPos
Sets the position of field captions relative to the field values for an entity record.
This property is normally used with the JavaScript Enumerator object.
Values
Examples
r = CRM.FindRecord('Company','Comp_companyid=30');
CompBlock = CRM.GetBlock('CompanyBoxLong');
eEntries = new Enumerator(CompBlock);
while (!eEntries.atEnd())
{
y = eEntries.item();
y.CaptionPos = 6;
eEntries.moveNext();
}
CRM.AddContent(CompBlock.Execute(r));
Response.Write(CRM.GetPage());
CreateScript
Specifies the server-side JavaScript that is run upon the creation of the entry instance.
Values
String. Specifies the JavaScript to run. Within the JavaScript, any of the current entry block properties can
be accessed.
Examples
r = CRM.FindRecord('Company','Comp_companyid=30');
EG = CRM.GetBlock('companyboxlong');
NewE = EG.GetBlock('comp_name');
NewE.CreateScript = "MaxLength=20";
CRM.AddContent(EG.Execute(r));
Response.Write(CRM.GetPage());
Sets the maximum length of the Entry block comp_name field instance to 20 characters.
DefaultType
Examples
R = CRM.CreateRecord('company');
EG = CRM.GetBlock('companyboxlong');
CompanyE = EG.GetEntry('comp_name');
CompanyE.DefaultType = 1;
CompanyE.DefaultValue = 'New company name';
CRM.AddContent(EG.Execute(R));
Response.Write(CRM.GetPage());
Sets the default value of the comp_name field to the value specified in the DefaultValue property.
DefaultValue
Specifies the default string value to use for the field when a new entity record is created.
Only use this property if you set the DefaultType property to 1.
Values
Examples
R = CRM.CreateRecord('company');
EG = CRM.GetBlock('companyboxlong');
E = EG.GetEntry('comp_name');
E.DefaultType = 1;
E.DefaultValue = 'My company name';
CRM.AddContent(EG.Execute(R));
Response.Write(CRM.GetPage());
Sets the default value of the comp_name field to My company name for each new company record being
created.
Values
Examples
Entry = CRM.GetBlock('entry');
Entry.FieldName = "Check Box";
Entry.EntryType = 45;
Sets the field caption of the new entry to My check box, and then sets the field type to check box (45).
Fam
Sets the caption family of the CRMEntryGroupBlock object. This property controls the captions that appear
on each entry.
By default, the caption shown is the translation of the caption family (column names) plus the caption code
(field name). You can change the caption by setting the Fam property value and adding a translation for the
Fam value and the field name.
To view a list of column names, go to <My Profile> | Administration | Customization | Translations.
Fam. Specifies the family name to use to find the translation for the entry caption. This must be a string
value.
Examples
c = CRM.GetContextInfo('company','Comp_CompanyId');
CompanyRec = CRM.FindRecord('company','Comp_CompanyId='+c);
CompanyBlock = CRM.GetBlock("companyboxlong");
name = CompanyBlock.GetEntry('comp_name');
name.Fam = 'My caption family';
Response.Write(CompanyBlock.Execute(CompanyRec));
FieldName
Values
Example
Entry = CRM.GetBlock("entry");
Entry.FieldName = "My check box";
Entry.EntryType = 45;
CRM.AddContent(Entry.Execute());
Response.Write(CRM.GetPage());
Sets the field caption of the new entry to My check box, and then sets the field type to check box (45).
Hidden
Values
Example
r = CRM.FindRecord('Company','Comp_companyid=22');
EG = CRM.GetBlock('companyboxlong');
NewE = EG.GetBlock('comp_revenue');
NewE.Hidden = true;
CRM.AddContent(EG.Execute));
Response.Write(CRM.GetPage());
JumpEntity
Values
l Company
l Person
l Communications
l Case
l Opportunity
l Solution
l Address
l Library
l Notes
Example
c = CRM.GetContextInfo('company','Comp_CompanyId');
CompanyRec = CRM.FindRecord('company','Comp_CompanyId='+c);
userLevel = CRM.GetContextInfo('user','User_Per_Admin');
LookUpFamily
Values
LookUpFamily. Specifies the name of the family. This must be a string value.
Examples
NewE = CRM.GetBlock("entry");
NewE.EntryType = 21;
NewE.Caption = "Days of the week";
NewE.LookupFamily = "DayName";
EG.AddBlock(NewE);
CRM.AddContent(EG.Execute());
Response.Write(CRM.GetPage());
Creates a new selection entry group that uses the DayName family for selection items.
MaxLength
Sets the maximum length of a field value (CRMEntryGroupBlock object). This doesn't change the size of the
entry box. To change the entry box size, use the Size parameter.
Values
MaxLength. Specifies the maximum length of value in characters. This must be an integer value.
Examples
r = CRM.FindRecord('Company','Comp_companyid=22');
EG = CRM.GetBlock('companyboxlong');
NewE = EG.GetBlock('comp_name');
NewE.MaxLength = 5;
CRM.AddContent(EG.Execute(r));
Response.Write(CRM.GetPage());
Sets if the user can select more than one item from the entry block list.
You must save the possible entries in a relevant location such as a link table.
This property is only applicable if the EntryType property is set to 21.
Values
Example
b = CRM.GetBlock('companyboxlong');
e = b.GetBlock('comp_source');
e.MultipleSelect = true;
e.Size = 10;
r = CRM.FindRecord('company','comp_companyid=892');
CRM.AddContent(b.Execute(r));
Response.Write(CRM.GetPage());
Sets the comp_source entry block of the companyboxlong entry group to MultipleSelect; also sets the entry
size to 10.
OnChangeScript
Values
Examples
ThisPersonId = CRM.GetContextInfo('Person','Pers_PersonId');
ThisPersonRecord = CRM.FindRecord('Person','Pers_PersonId=17');
PersonBlock = CRM.GetBlock('PersonBoxLong');
FirstName = PersonBlock.GetEntry('Pers_FirstName');
FirstName.OnChangeScript = "alert('User's first name has changed')";
CRM.AddContent(PersonBlock.Execute(ThisPersonRecord));
Response.Write(CRM.GetPage());
ReadOnly
Values
Example
Record=CRM.FindRecord('person', 'pers_personid=17');
PersonBlock = CRM.GetBlock('PersonBoxLong');
Title = PersonBlock.GetEntry('pers_titlecode');
Title.ReadOnly = 'true';
CRM.AddContent(PersonBlock.Execute(Record));
Response.Write(CRM.GetPage());
Required
Values
l true. Specifies that the field is required and must be populated with a value.
l false. Specifies that the field is optional.
Examples
Block = CRM.GetBlock('PersonBoxShort');
Title = Block.GetEntry('pers_title');
Title.Required = true;
CRM.AddContent(Block.Execute());
Response.Write(CRM.GetPage());
Size
Specifies the maximum field size in characters. This is the field size displayed on the screen.
Integer
Examples
ThisPersonId = CRM.GetContextInfo('Person','Pers_PersonId');
ThisPersonRecord = CRM.FindRecord('Person','Pers_Personid='+ThisPersonId);
PersonBlock = CRM.GetBlock('PersonBoxLong');
FirstName = PersonBlock.GetEntry('Pers_FirstName');
FirstName.Size = 40;
CRM.AddContent(PersonBlock.Execute(ThisPersonRecord));
Response.Write(CRM.GetPage());
Retrieves the pers_firstname field from the PersonBoxLong screen, and then sets the maximum size of the
field to 40 characters.
ValidateScript
Specifies the server-side validation JavaScript to run when the entry is executed in save mode.
The script sets the Valid variable to one of these values:
Values
JavaScript to run. This must be a string value. You can set the ErrorStr variable in your script to display a
custom error message.
Examples
r = CRM.FindRecord('Company','Comp_companyid=30');
EG = CRM.GetBlock('companyboxlong');
NewE = EG.GetBlock('comp_name');
NewE.ValidateScript = "Valid = (comp_name.value != '');if (!Valid)
ErrorStr = 'Please correct the highlighted entries';";
CRM.AddContent(EG.Execute(r));
Response.Write(CRM.GetPage());
The script in this example sets the Valid variable to true if the comp_name field is not empty (comp_
name.value != '').
If the comp_name field is empty, the following error message is displayed: "Please correct the highlighted
entries".
Values
Examples
EntryGroup = CRM.GetBlock('companyboxlong');
Record = CRM.FindRecord('Company','Comp_CompanyId=30');
UserSelect = EntryGroup.GetBlock('comp_primaryuserid');
UserSelect.AllowUnassigned = true;
UserSelect.AllowBlank = false;
CRM.AddContent(EntryGroup.Execute(Record));
Response.Write(CRM.GetPage());
Changes the option caption from None to Unassigned.When a user clicks Change, the Account
Manager list includes the Unassigned option instead of None.
Restrictor
Specifies an Advanced Search Select field that restricts the search values for the field.
Values
Restrictor = "cmli_comm_companyid";
Adds a new Advanced Search Select field to restrict search results based on an existing Advanced Search
Select field. The existing field searches for companies; when a company is selected for the existing field the
new Advanced Search field searches for records that belong to that company.
CopyErrorsToPageErrorContent
Specifies where to display validation errors related to a particular block on the page.
Values
Examples
CompanyEntryGroup = CRM.GetBlock("CompanyBoxLong");
CompanyEntryGroup.Title = "Company";
AddressEntryGroup = CRM.GetBlock("AddressBoxLong");
AddressEntryGroup.Title = "Address";
// Set Valid = false so that this field will always fail validation no
matter what is entered.
var address1field = AddressEntryGroup.GetEntry("addr_address1");
address1field.ValidateScript = "Valid = false; ErrorStr = 'Value not
correct'";
// Set CopyErrorsToPageErrorContent = true for both of the blocks so that
the error message
// will appear at the top of the page.
CompanyEntryGroup.CopyErrorsToPageErrorContent = true;
AddressEntryGroup.CopyErrorsToPageErrorContent = true;
container=CRM.GetBlock("container");
container.AddBlock(CompanyEntryGroup);
container.AddBlock(AddressEntryGroup);
Creates two entry blocks, one of which fails validation. The corresponding validation errors are displayed at
the top of the page.
l Change or Save. Displayed as Change when the screen is in View mode and Save when the
screen is in Edit mode. This button is shown by default.
l Delete or Confirm Delete. Displayed as Delete when the screen is in View mode and Confirm
Delete when the screen is in Confirm Delete mode. This button is not shown by default.
l Continue or Cancel. Displayed as Continue when the screen is in View mode and Cancel when
the screen is in Edit or Confirm Delete mode. This button is not shown by default.
In this section:
l CRMEntryGroupBlock methods
l CRMEntryGroupBlock properties
CRMEntryGroupBlock methods
l AddEntry(EntryName, Position, Newline). Enables new entries to be added dynamically to
EntryGroups.
l DeleteEntry(EntryName). Deletes the specified entry from the EntryGroup.
l GetEntry. Returns a reference to the specified entry.
Enables new entries to be added dynamically to EntryGroups. The changes only apply to the ASP page in
which they are used.
Parameters
l EntryName (required). Specifies the new entry to be added. The entry can be passed in as the field
name or an existing EntryBlock. In any case, the field must be relevant to the existing EntryGroup
block. It must exist in the table on which the EntryGroup block is based.
l Position (optional). Specifies the position in the group at which to add the entry.
Possible values:
l <a positive integer>. Specifies the index of the position at which to add the entry.
l 0. Adds the entry to the first position in the group.
l -1 (default). Adds the entry to the last position in the group.
l NewLine (optional). Specifies whether to show the entry on a new line.
Possible values:
Return value
CRMEntryBlock object
Examples
var EntryGroup;
EntryGroup = CRM.GetBlock("personboxlong");
EntryGroup.AddEntry("pers_faxnumber", 0, false);
EntryGroup.AddEntry("pers_phonenumber", 0, false);
CRM.AddContent(EntryGroup.Execute());
Response.Write(CRM.GetPage());
Adds the pers_faxnumber and pers_phonenumber fields to the start of the entry group.
DeleteEntry(EntryName)
Parameters
Return value
None
Examples
var r;
r = CRM.FindRecord('Company','Comp_CompanyId=30');
MyC = CRM.GetBlock('CompanyBoxLong');
userLevel = CRM.GetContextInfo('user','User_Per_Admin');
if (userLevel < 3)
{
MyC.DeleteEntry('comp_revenue');
}
CRM.AddContent(MyC.Execute(r));
Response.Write(CRM.GetPage());
Parameters
Return value
Examples
ThisPersonId = CRM.GetContextInfo('Person','Pers_PersonId');
ThisPersonRecord = CRM.FindRecord('Person','Pers_Personid='+ThisPersonId);
PersonBlock = CRM.GetBlock('PersonBoxShort');
FirstName = PersonBlock.GetEntry('Pers_FirstName');
FirstName.ReadOnly = true;
CRM.AddContent(PersonBlock.Execute(ThisPersonRecord));
Response.Write(CRM.GetPage());
Retrieves the pers_fistname entry from the PersonBoxShort EntryGroup and sets the entry to read-only.
CRMEntryGroupBlock properties
ShowSavedSearch. When the block is executed, shows or hides the Saved Search functionality as part of
the entry group.
ShowSavedSearch
When the block is executed, shows or hides the Saved Search functionality as part of the entry group.
This property is only applicable to EntryGroup blocks whose screen type is Search block and that have an
associated List.
Values
searchEntry = CRM.GetBlock("ProjectsSearchBox");
searchEntry.ShowSavedSearch=true;
searchList = CRM.GetBlock("ProjectsGrid");
searchContainer = CRM.GetBlock("container");
searchContainer.ButtonTitle = "Search";
searchContainer.ButtonImage = "Search.gif";
searchContainer.AddBlock(searchEntry);
if( CRM.Mode != 6)
searchContainer.AddBlock(searchList);
searchContainer.AddButton(CRM.Button("Clear", "clear.gif",
"javascript:document.EntryForm.em.value = '6';document.EntryForm.su
bmit();"));
searchList.ArgObj = searchEntry;
CRM.AddContent(searchContainer.Execute(searchEntry));
Response.Write(CRM.GetPage());
You can use the Translate property which allows you to dynamically choose a file based on the user's
language code, or the ProperCase property which allows you to display the text with initial caps. These
simple ASP statements include the named file on the page. If the author sets translate to true, the file name
included is changed from filename to filename_US or filename_DE, depending on the user's language
specified in Sage CRM. If the file name extension is not specified, .txt is used by default. This means you
must specify .htm and format the text.
l CRMFileBlock properties
CRMFileBlock properties
l DirectoryPath. Specifies the folder that stores the files.
l FileName. Specifies the name of the file to use.
l ProperCase. Applies initial capitals formatting to the text: the first letter of every word begins with a
capital letter.
l Translate. Specifies to use files containing text in the user's language.
DirectoryPath
Specifies the folder that stores the files. If you omit this parameter, the following path is used by default:
<Sage CRM installation folder>\WWWRoot\Reports
By default, the Sage CRM installation folder is as follows:
Values
var afile;
afile = CRM.GetBlock('file');
afile.FileName = 'Results.htm';
afile.DirectoryPath = 'c:\\MyFolder\\Storage';
FileName
Values
Examples
var afile;
afile = CRM.GetBlock('file');
afile.FileName = 'Results.htm';
ProperCase
Applies initial capitals formatting to the text: the first letter of every word begins with a capital letter.
Values
Example
var afile;
afile = CRM.GetBlock('file');
afile.FileName = 'general.htm';
afile.ProperCase = true;
CRM.AddContent(afile.Execute());
Response.Write(CRM.GetPage());
Translate
Specifies to use files containing text in the user's language. Names of these files have the following format:
<file name>_<language>.<extension>
Values
Examples
var afile;
afile = CRM.GetBlock('file');
afile.FileName = 'Results.htm';
afile.Translate = true;
l CRMGraphicBlock methods
l CRMGraphicBlock properties
CRMGraphicBlock methods
l Arc(X1, Y1, X2, Y2, X3, Y3, X4, Y4). Draws an elliptically curved line.
l Animation(Mode, Value). Sets animation parameters.
l Brush(Mode, Value). Changes the color and pattern used when drawing the background or filling in
graphical shapes.
l Chord(X1,Y1,X2,Y2,X3,Y3,X4,Y4). Creates a shape that is defined by an arc and a line that joins the
endpoints of the arc.
l Effect(Mode, Value). Applies effects.
l Ellipse(X1,Y1,X2,Y2). Draws a circle or ellipse.
l FlipHoriz(). Flips the image horizontally.
l FlipVert(). Flips the image vertically.
l Font(Mode, Value). Changes the current font.
l FontColor(Color). Changes the color of the current font.
l FontSize(Size). Changes the size of the current font.
l GradientFill(StartColor, EndColor, Direction, Colors). Fills the graphic with a gradient of colors.
l GrayScale(). Converts an image to grayscale.
l LoadBMP(Filename). Loads a specified bitmap file as the new image.
l LoadImage(text). Loads image from the specified file.
Parameters
l X1. Integer.
l Y1. Integer.
l X2. Integer.
l Y2. Integer.
l X3. Integer.
l Y3. Integer.
l X4. Integer.
l Y4. Integer.
var graphic;
graphic = CRM.GetBlock("graphic");
graphic.ImageWidth = 70;
graphic.ImageHeight = 50;
graphic.Effect('ChangeColor','White,Red');
graphic.Arc(10,10,25,25,30,30,40,40);
CRM.AddContent(graphic.execute());
Response.Write(CRM.GetPage());
Animation(Mode, Value)
Parameters
l Mode. WideString.
l Value. Integer.
Example
Graphic.Animation('Delay','100');
Graphic.Animation('Loop','0');
Graphic.Animation('Add','100');
Brush(Mode, Value)
Changes the color and pattern used when drawing the background or filling in graphical shapes. You can
select one of predefined patterns by using the Style mode or load a pattern from an image by using the Load
mode.
Parameters
l Mode. Specifies the mode to use. This parameter accepts a WideString value.
l Value. Specifies the value for the selected mode. This parameter accepts a WideString value.
Examples
Graphic.Brush('Load','c:\\MyImages\\SoapBubbles.bmp');
Graphic.Brush('Color','Blue');
Chord(X1,Y1,X2,Y2,X3,Y3,X4,Y4)
Creates a shape that is defined by an arc and a line that joins the endpoints of the arc.
The chord consists of a portion of an ellipse that is bound by the points (X1,Y1) and (X2,Y2). The ellipse is
bisected by a line that runs between the points (X3,Y3) and (X4,Y4). The perimeter of the chord runs
counter clockwise from (X3, Y3), counterclockwise along the ellipse to (X4,Y4), and straight back to
(X3,Y3). If (X3,Y3) and (X4,Y4) are not on the surface of the ellipse, the corresponding corners on the chord
are the closest points on the perimeter that intersect the line.
Parameters
l X1. Integer.
l Y1. Integer.
l X2. Integer.
l Y2. Integer.
l X3. Integer.
l Y3. Integer.
l X4. Integer.
l Y4. Integer.
Examples
Graphic.Chord(10,10,25,25,30,30,40,40);
Effect(Mode, Value)
Applies effects.
Parameters
Examples
Graphic.Effect('Zoom','200');
Graphic.Effect('Transparent','True');
Graphic.Effect('Dither','Floyd');
Graphic.Effect('Merge','c:\\winnt\\winnt.bmp, White,0,0');
Graphic.Effect('DisplayErrors','false');
Graphic.Effect('Clear','');
Graphic.Effect('ChangeColor','White,Red');
Parameters
l X1. Integer.
l Y1. Integer.
l X2. Integer.
l Y2. Integer.
Examples
Graphic = CRM.GetBlock("graphic");
Graphic.ImageWidth = 70;
Graphic.ImageHeight = 50;
Graphic.Effect('ChangeColor','White,Red');
Graphic.Ellipse(10,10,50,50);
CRM.AddContent(Graphic.execute());
Response.Write(CRM.GetPage());
FlipHoriz()
Parameters
None
Examples
Graphic.FlipHoriz();
FlipVert()
Parameters
None
Graphic.FlipVert();
Font(Mode, Value)
Changes the current font. For best results, use TrueType fonts. To apply changes, use the TextOut(X, Y,
Text, transparent=True/False) method.
Parameters
l Mode. Specifies changes to apply to the font. This parameter can take one of the following
WideString values:
l Name. Changes the current font. Use the Value parameter to specify the name of the font to
use.
l Size. Changes the font size. Use the Value parameter to specify the font size.
l Color. Changes the font color. Use the Value parameter to specify the font color.
l Bold. Toggles between bold and normal font. Use the Value parameter to apply bold (true)
or normal (false) font.
l Italic. Toggles between italic and normal font. Use the Value parameter to apply italic (true)
or normal (false) font.
l Underline. Toggles between underlined and normal font. Use the Value parameter to apply
underlined (true) or normal (false) font.
l Strikeout. Adds or removes a line through the middle of characters. Use the Value
parameter to add a line (true) or remove the line (false).
l Rotate. Rotates the font. This parameter may not work for some fonts.
l Value. Specifies the value for the Mode parameter. This parameter accepts a WideString value.
Examples
FontColor(Color)
Changes the color of the current font. This method is identical to Font(Color, Value).
Parameters
Color. Specifies the name of the font color to use. This parameter accepts a WideString value.
Example
Graphic.FontColor('blue');
FontSize(Size)
Changes the size of the current font. This method is identical to Font(Size, Value).
Parameters
Example
Graphic.FontSize(24);
Parameters
l StartColor. Specifies the initial color of the gradient. This parameter accepts a WideString value.
l EndColor. Specifies the end color of the gradient. This parameter accepts a WideString value.
l Direction. Specifies the direction in which the gradient color changes. This parameter can take one
of the following WideString values:
Examples
Graphic.GradientFill('Yellow','White','LeftToRight');
Graphic.GradientFill('Blue','White','TopToBottom',256);
GrayScale()
Converts an image to grayscale. This method doesn't reduce the number of colors in use.
Parameters
None
Examples
Graphic.Grayscale();
LoadBMP(Filename)
Parameters
Filename. Specifies path to the image in the form of absolute server address. This parameter accepts a
WideString value.
Examples
Graphic = CRM.GetBlock('graphic');
Graphic.LoadBMP("D:\\Program Files\\Sage\\CRM\\CRM\\WWWRoot\\Img
\\plain.bmp");
CRM.AddContent(Graphic.Execute());
Response.Write(CRM.GetPage());
l .bmp
l .ico
l .gif
l .jpg
l .wmf
l .emf
Parameters
Examples
Graphic.LoadImage('Image.gif');
Loads image from a file named Image.gif located in the following folder on the Sage CRM server:
<Sage CRM installation folder>\WWWRoot\Img
Graphic.LoadImage('c:\\MyImages\\Image.gif');
Loads image from a file named Image.gif located in the C:\MyImages folder on the Sage CRM server.
LoadJPG(Filename)
Parameters
Examples
Graphic = CRM.GetBlock('graphic');
Graphic.LoadJPG("C:\\Program
LineTo(X,Y)
Draws a line from the current pen position up to the points specified in the method parameters.
The points specified in the parameters are not included in the line. Changes the pen position to the specified
points. The line is drawn using the current pen and color.
To set the initial pen position for drawing a line, use the MoveTo(X,Y).
Parameters
Use the below parameters to specify the coordinates for drawing a line.
l X. Integer.
l Y. Integer.
Examples
Graphic.LineTo(50,50);
Monochrome()
Parameters
Boolean. Specifies whether to convert the image to monochrome. This parameter can take one of the
following values:
Examples
Graphic.Monochrome(true);
MoveTo(X,Y)
l X. Integer.
l Y. Integer.
Examples
Graphic.MoveTo(50,50);
Pen(Mode, Value)
Parameters
l Mode. Specifies the pen style to use. This parameter can take one of the following WideString
values:
l Style. Specifies the line style to use, for example, DashDot.
l Color. Specifies the color to use.
l Width. Specifies the line width in pixels.
l Value. Specifies the value for the Mode parameter. This parameter accepts a WideString value.
Examples
Graphic.Pen('Style','DashDot');
Graphic.Pen('Color','Blue');
Graphic.Pen('Width','3');
PenColor(Color)
Parameters
Color. Specifies the color to use. This parameter accepts a WideString value.
Examples
Graphic.PenColor('green');
Parameters
Example
Example Graphic.PenWidth('3');
PieShape(X1,Y1,X2,Y2,X3,Y3,X4,Y4)
Parameters
l X1. Integer.
l Y1. Integer.
l X2. Integer.
l Y2. Integer.
l X3. Integer.
l Y3. Integer.
l X4. Integer.
l Y4. Integer.
Examples
Graphic.PieShape(10,10,25,25,30,30,40,40);
Rectangle(X1,Y1,X2,Y2)
Draws a rectangle.
Specify the rectangle by giving the top left point at pixel coordinates (X1, Y1) and the bottom right point at
(X2, Y2). The rectangle is drawn using the current pen width and color.
l X1. Integer.
l Y1. Integer.
l X2. Integer.
l Y2. Integer.
Examples
Graphic.Rectangle(10,10,100,100);
Resize(Width, Height)
Parameters
l Width. Integer.
l Height. Integer.
Examples
Graphic.Resize(150,100);
Rotate(Number)
Rotates an image.
The corners of a rotated image are colored in the current brush color.
Parameters
Number. Specifies the number of degrees by which to rotate the image. This parameter accepts an integer
value.
Examples
Graphic.Rotate(90);
RoundRect(X1,Y1,X2,Y2,X3,Y3)
Parameters
l X1. Integer.
l Y1. Integer.
l X2. Integer.
l Y2. Integer.
l X3. Integer.
l Y3. Integer.
Examples
Graphic.RoundRect(10,10,12,12,15,15);
SaveAsJPG(text)
Saves the current image as a .jpeg file with 16-bit color depth.
Parameters
Text. Specifies path to the file. This parameter accepts a WideString value.
Examples
Graphic.SaveAsJPG('c:\\cancel.jpg');
Parameters
l X, Y. Specify coordinates for writing text. These parameters accept integer values.
l Text. Specifies the text to write. Accepts a WideString value.
l Transparent. Specifies whether the text is transparent. This parameter accepts one of the following
values:
l true. Makes the text transparent.
l false. Makes the text non-transparent.
Graphic.TextOut(10,10,'My text',true);
Writes text on an image and centers it in a rectangle area defined by the parameters.
Parameters
Example
Graphic.TextOutCenter(10,10,100,30,'My text',true,true);
CRMGraphicBlock properties
l Border. Sets the thickness of the border around the image.
l Description. Sets the description of the image.
l hSpace. Adds a horizontal space above and below the image.
l ImageHeight. Sets the height of the box in which the image is loaded.
l ImageWidth. Sets the width of the box in which the image is loaded.
l SaveAsGifs. Saves an image as a .gif or .jpeg file.
l vSpace. Adds a vertical space to the left and to the right of the image.
Border
Values
Graphic.Border = 1;
Description
Values
Examples
hSpace
Values
Integer. Specifies the size of the horizontal space to add. By default, this value is 0.
Examples
Graphic.hSpace = 10;
ImageHeight
Values
Example
Graphic.ImageHeight = 200;
ImageWidth
Examples
Graphic.ImageWidth = 200;
SaveAsGifs
Values
When the Sage CRM server graphics adapter is configured to allow for 16-bit color depth or greater, this
property is set to false by default. Otherwise, this property is set to true.
Examples
Graphic.SaveAsGifs = true;
vSpace
Adds a vertical space to the left and to the right of the image.
Values
Integer. Specifies the size of the vertical space to add. By default, this value is 0.
Examples
Graphic.vSpace = 10;
l CRMGridColBlock properties
l Code example: CRMGridColBlock object
CRMGridColBlock properties
l Alignment. Sets the alignment of text within the column.
l AllowOrderBy. Sorts entries in the list by the values in the column.
l CustomActionFile. Hyperlinks a column to an ASP file.
l CustomIdField. Allows a value to be passed to the custom file when the corresponding column is
selected.
l JumpEntity. Adds a hyperlink that opens the summary screen of an entity record.
l ShowHeading. Shows or hides the column heading.
l ShowSelectAsGif. Shows the values in the column as GIF image
Alignment
Values
l Left (default)
l Right
l Center
Examples
CaseListBlock = CRM.GetBlock('CaseListBlock');
Source = CaseListBlock.AddGridCol('Case_Source');
Source.AllowOrderBy = true;
AllowOrderBy
Values
Example
CaseListBlock = CRM.GetBlock('CaseListBlock');
FoundIn = CaseListBlock.AddGridCol('Case_FoundVer');
FoundIn.AllowOrderBy = true;
CRM.AddContent(CaseListBlock.Execute());
Response.Write(CRM.GetPage());
Adds a new column (Case_FoundVer) to the list and sorts entries in the list by that column.
CustomActionFile
Values
Examples
list = CRM.GetBlock('CompanyGrid');
g = list.GetGridCol('comp_name');
g.JumpAction = 430;
g.CustomIdField = 'comp_companyid';
g.CustomActionFile = 'invoices.asp';
CRM.AddContent(list.Execute("comp_name like 'eu'"));
Response.Write(CRM.GetPage());
or
a = Request.QueryString("field");
If there's a possibility of a QueryString field being duplicated, test its length and reassign the variable.
CustomIdField
Allows a value to be passed to the custom file when the corresponding column is selected. The value is
passed to the query string in the following form:
<FieldName> = <Value>
Values
Examples
list = CRM.GetBlock('CompanyGrid');
g = list.GetGridCol('comp_name');
g.JumpAction = 430;
g.CustomIdField = 'comp_companyid';
g.CustomActionFile = 'test.asp';
CRM.AddContent(list.Execute("comp_name like 'o%'"));
Response.Write(CRM.GetPage());
Sets the ID field for the custom jump to the comp_companyid field.
JumpEntity
Values
l company
l person
Examples
PersonList = CRM.GetBlock("persongrid");
GridCol = PersonList.GetGridCol("pers_firstname");
GridCol.JumpEntity = "person";
CRM.AddContent(PersonList.Execute(''));
Response.Write(CRM.GetPage());
Adds a hyperlink to the pers_firstname field. When a user clicks the hyperlink, the person's summary screen
opens.
ShowHeading
Values
Examples
CaseListBlock = CRM.GetBlock('CaseListBlock');
Source = CaseListBlock.AddGridCol('Case_Source');
Source.ShowHeading = false;
Source.Alignment = 'LEFT';
CRM.AddContent(CaseListBlock.Execute());
Response.Write(CRM.GetPage());
Adds a column case_source to the case list. The column heading is hidden.
ShowSelectAsGif
Examples
GridCol.ShowSelectAsGif = true;
// Add the Person fax number as the third column in the list, with no
heading.
GridCol = PersonList.AddGridCol("pers_faxnumber",2);
GridCol.ShowHeading = false;
%>
l CRMListBlock methods
l CRMListBlock properties
l Code example: CRMListBlock object
CRMListBlock methods
l AddGridCol(ColName, Position, AllowOrderBy). Adds a new grid column dynamically to a List block.
l DeleteGridCol(ColName). Deletes the specifies column from the list.
l Execute(Arg). Displays a list.
l GetGridCol. Returns a reference to the specified grid column.
Parameters
l ColName (required). Specifies the name of the field to be added as a column. The field must be
relevant to the List block. It must be available in the table or view on which the List block is based.
l Position (optional). Specifies the position at which to add the column.
Possible values:
l <a positive integer>. Specifies the index of the position at which to add the column.
l 0. Adds the column to the first position.
l -1 (default). Adds the column to the last position.
l AllowOrderBy (optional). Specifies if the entries in the column can be sorted.
Possible values:
l true. Specifies that the entries cannot be sorted.
l false (default). Specifies that the entries can be sorted.
MyList = CRM.GetBlock('CompanyGrid');
MyList.AddGridCol('comp_revenue', -1, true);
CRM.AddContent(MyList.Execute());
Response.Write(CRM.GetPage());
Adds a new column comp_revenue to the end of the company grid list. The entries in the new column can be
sorted.
DeleteGridCol(ColName)
Parameters
Examples
ListBlock = CRM.GetBlock("companygrid");
ListBlock.DeleteGridCol("comp_website");
CRM.AddContent(ListBlock.Execute());
Response.Write(CRM.GetPage());
Execute(Arg)
Displays a list.
Parameters
Examples
ListBlock = CRM.GetBlock("companygrid");
CRM.AddContent(ListBlock.Execute("comp_type='Customer'"));
Response.Write(CRM.GetPage());
Uses the result of the entrygroup search as the argument for the list.
GetGridCol
Parameters
Return value
Examples
ListBlock = CRM.GetBlock("companygrid");
Column = ListBlock.GetGridCol("comp_name");
Column.allowOrderby = true;
CRM.AddContent(ListBlock.Execute());
Response.Write(CRM.GetPage());
Returns the comp_name column and configures the list to be ordered by this column.
CRMListBlock properties
l CaptionFamily. Sets the caption family for a list.
l PadBottom. Shows or hides empty rows in a list.
l prevURL. Specifies the URL of the ASP page to return to.
l RowsPerScreen. Sets the maximum number of rows displayed on each screen.
l SelectSql. Specifies the SQL statement to select items in the list.
CaptionFamily
Sets the caption family for a list. As a result, translations can be added for the captions at the top of the list.
Values
Examples
MyList = CRM.GetBlock('CompanyGrid');
MyList.CaptionFamily = "Campaigns";
CRM.AddContent(MyList.Execute());
Response.Write(CRM.GetPage());
PadBottom
Values
l true(default). Shows empty rows. In this case, the number of rows shown always equals the value
set in the RowsPerScreen property.
l false. Hides empty rows.
Examples
List = CRM.GetBlock('companygrid');
List.RowsPerScreen = 8;
List.PadBottom = false;
CRM.AddContent(List.Execute());
Response.Write(CRM.GetPage());
Hides empty rows. The column heading is displayed even if there are no rows to display.
prevURL
Values
Examples
&Key-1=iKey_CustomEntity&PrevCustomURL=PrevUrl
Specifies that the previous dominant key was a custom page and where to go back to.
RowsPerScreen
Parameters
None
Examples
ListBlock = CRM.GetBlock("CompanyGrid");
ListBlock.RowsPerScreen = 8;
CRM.AddContent(ListBlock.Execute());
Response.Write(CRM.GetPage());
SelectSql
Value
Examples
NewList = CRM.GetBlock("list");
NewList.SelectSql = "Select * from vCompany";
NewList.AddGridCol("Comp_Name");
CRM.AddContent(NewList.Execute());
Response.Write(CRM.GetPage());
%>
l CRMMarqueeBlock properties
CRMMarqueeBlock properties
l HorizontalMinimum. Sets the start point of horizontal scrolling.
l HorizontalMaximum. Sets the end point of horizontal scrolling.
l VerticalMinimum. Sets the start point of vertical scrolling.
l VerticalMaximum. Sets the end point of vertical scrolling.
l ScrollSpeed. Sets the scrolling speed.
l StyleSheet. Specifies the Cascading Style Sheet (CSS) to use.
HorizontalMinimum
Values
Example
Marq = CRM.GetBlock('marquee');
Marq.HorizontalMinimum = 0;
HorizontalMaximum
Values
Example
Marq = CRM.GetBlock('marquee');
Marq.HorizontalMaximum = 850;
Values
Examples
Marq = CRM.GetBlock('marquee');
Marq.VerticalMinimum = 100;
VerticalMaximum
Values
Examples
Marq = CRM.GetBlock('marquee');
Marq.VerticalMaximum = 350;
ScrollSpeed
Values
Example
Marq = CRM.GetBlock('marquee');
Marq.ScrollSpeed = 200;
Values
Text. Specifies the .css file name. The default value is DiagonalText. This must be a WideString value.
Examples
Marq = CRM.GetBlock('marquee');
Marq.StyleSheet = 'NewStyle.css';
l An email server configured to redirect all incoming messages originating from a specified domain to
the same folder.
l An SMS gateway referring to this folder and the related mobile phone connection.
To enable the CRMMessageBlock object, log on to Sage CRM as a system administrator, go to <My
Profile> | Administration | E-mail And Documents | E-mail Configuration, and then configure the
following options:
l Outgoing Mail Server (SMTP). Specify the IP address of the SMTP server you want to use for
sending email messages.
l SMTP User Name. Enter the user name of the account with which you want to access the
SMTP server.
l SMTP Password. Enter the password for the specified access account.
l SMTP Port. Specify the SMTP port you want to use. By default, this is port 25.
l SMS Domain Name. Specify the mail domain used to hold the SMS messages, for example
sms.domain.com.
l SMTP Server For SMS Messaging. Specify the SMTP server you want to use for sending SMS.
You can specify a valid IP address or FQDN, such as mail.sms.domain.com.
l Use SMS Feature. Set this option to Yes to enable SMS messaging.
l SMS From Address. Specify a valid email address in the person profile.
The message details (recipients, CC, BCC, subject, body) are retrieved from the form content, if the
DisplayForm property is set to true.
The properties specified in the ASP page are defaults for the first value of the entry components of the form,
unless the Mode property is set to 2 (send).
CRMMessageBlock properties
l DisplayForm. Shows or hides an email form.
l mAddressFrom. Sets sender's email address.
l mNameFrom. Sets sender's name.
l mBody. Sets the body text of the message.
l mErrorMessage. Displays the related error if the message isn't sent successfully.
l mSentOK. Displays the status of the sent message.
l mShowCC. Shows or hides the CC field (carbon copy) in the Sage CRM user interface.
l mShowBCC. Shows or hides the BCC field (blind carbon copy) in the Sage CRM user interface.
l mSubject. Sets the subject of the message.
DisplayForm
Values
Example
var MailObj;
MailObj = CRM.GetBlock("messageblock");
MailObj.Mode = 2;
MailObj.DisplayForm = false;
CRM.AddContent(MailObj.Execute());
Response.Write(CRM.GetPage());
Sends a message without displaying the email form. Displays the email form only if there are errors.
mAddressFrom
Examples
MailObj.mAddressFrom = '[email protected]';
MailObj.mNameFrom = 'George Smith';
mNameFrom
Values
Examples
MailObj.mAddressFrom = '[email protected]';
MailObj.mNameFrom = 'George Smith';
mBody
Values
Text
Example
MailObj = CRM.GetBlock("messageblock");
MailObj.mBody = 'This is message text.';
CRM.AddContent(mailObj.execute());
Response.Write(CRM.GetPage());
Values
Text (read-only)
Examples
if(!mSentOK)
{
// If errors occurred then show the proper message.
CRM.AddContent('Error: '+mErrorMessage);
}
else
{
CRM.AddContent('Message Sent OK'());
}
Response.Write(CRM.GetPage());
mSentOK
Values
Examples
if(!MailObj.mSentOK) {
// If an error occurs, then show the corresponding error message.
CRM.AddContent('ERROR: ' + MailObj.mErrorMessage);
}
else {
CRM.AddContent('Message was sent successfully.');
}
Response.Write(CRM.GetPage());
with (MailObj) {
if(!mSentOK) { // If an error occurs, then show the corresponding error
message.
CRM.AddContent('ERROR: ' + mErrorMessage);
The examples above display "Message was sent successfully" if the message was sent successfully.
Otherwise, they display the corresponding error message.
mShowCC
Shows or hides the CC field (carbon copy) in the Sage CRM user interface.
Values
Examples
MailObj = CRM.GetBlock("messageblock");
MailObj.mSubject = 'New Message';
MailObj.mBody = "This is where you put the content of the message.";
MailObj.mShowCC = true;
CRM.AddContent(mailObj.execute());
Response.Write(CRM.GetPage());
mShowBCC
Shows or hides the BCC field (blind carbon copy) in the Sage CRM user interface.
Values
Examples
MailObj = CRM.GetBlock("messageblock");
MailObj.mSubject = 'New Message';
MailObj.mBody = "This is where you put the content of the message.";
MailObj.mShowBCC = true;
CRM.AddContent(mailObj.execute());
Response.Write(CRM.GetPage());
mSubject
Values
String
Examples
MailObj = CRM.GetBlock("messageblock");
MailObj.mSubject = 'My message subject';
CRM.AddContent(mailObj.execute());
Response.Write(CRM.GetPage());
CRMOrgGraphicBlock methods
OrgTree(Mode, Value). Adds parent and child items for the CRMOrgGraphicBlock object and sets the
appearance of the organizational chart.
OrgTree(Mode, Value)
Adds parent and child items for the CRMOrgGraphicBlock object and sets the appearance of the
organizational chart.
Syntax
OrgTree
('Add','<ParentName>,<Name>,<Child=true/false>,<URL>,<Description>,<Relati
onship>');
Parameters
l Mode. WideString.
l Value. WideString.
Examples
OrgGraph.OrgTree('Add',',Top Level,True');
OrgGraph.OrgTree('Add','Top Level,Child,True');
OrgGraph.OrgTree('GetLevelCount','1');
OrgGraph.OrgTree('GetLargestLevelSize','');
OrgGraph.OrgTree('Animated','False');
OrgGraph.OrgTree('FullBoxWidth','88');
OrgGraph.OrgTree('FullBoxHeight','50');
OrgGraph.OrgTree('BoxWidth','40');
OrgGraph.OrgTree('BoxHeight','25');
OrgGraph.OrgTree('EntityIcon','c:\\person.bmp');
OrgGraph.OrgTree('EntityImage','c:\\back.bmp');
l CRMPipelineGraphicBlock methods
l CRMPipelineGraphicBlock properties
CRMPipelineGraphicBlock methods
l AddPipeEntry(Name, Value, Description). Adds a pipe section to the pipeline diagram.
l ChooseBackGround(Value). Sets the background of the pipeline diagram.
l PipelineStyle(Mode, Value). Changes the appearance and size of individual sections of the pipeline
graphic.
Parameters
l Name. Specifies the name of the pipe section to show in the pipeline legend. This parameter accepts
a WideString value.
l Value. Specifies the percentage that the pipe section takes in the pipeline diagram. This parameter
accepts an integer value.
l Description. Specifies the tooltip that appears when the user points to the pipe section.
l Url. Specifies the URL (such as web page or ASP page) to open when the user clicks the pipe
section.
Examples
MyPipe = CRM.GetBlock('pipeline');
MyPipe.AddPipeEntry('Sold', 100,'100 items sold',
ChooseBackGround(Value)
Parameters
Value. Specifies the background image file to use. The default background is white. This parameter can
take one of the following values:
l 1. accpacblue.gif
l 2. accpacwhite.gif
l 5. listrow1gif
l 8. lightpurplemarblebright.gif
l 14. accpaccream.gif
l 15. listrow2.gif
You can find these files in the following folder on the Sage CRM server:
<Sage CRM installation folder>\WWWRoot\Themes\Img\default\Backgrounds
Examples
Pipe.ChooseBackGround(8);
Uses the lightpurplemarblebright.gif file as the background for the pipeline diagram.
PipelineStyle(Mode, Value)
Changes the appearance and size of individual sections of the pipeline graphic. For example, you can
change gradients or legends.
Parameters
Mode. WideString.
Example
MyPipe = CRM.GetBlock('pipeline');
MyPipe.AddPipeEntry('Sold', 100,'100 items sold', 'http://www.crm.com');
MyPipe.AddPipeEntry('Prospect', 40,'40 prospects',
'http://www.yahoo.com');
MyPipe.PipelineStyle('Shape','Circle');
CRMPipelineGraphicBlock properties
l Pipe_Summary. Sets a summary for the pipe section in HTML format.
l Selected. Selects a pipe section.
Pipe_Summary
Parameters
Value. HTML code.
Example
Pipleline = CRM.GetBlock('pipeline');
Pipe = Pipleline.Selected(1);
Pipe.Pipe_Summary = '<table><td class=tablehead>Negotiating Selected (70)
</td></table>';
Selected
Parameters
Examples
Pipeline = CRM.GetBlock('pipeline');
Pipeline.Selected(1);
l CRMQuery properties
CRMQuery methods
l ExecSql(). Executes the SQL statement.
l Next(). Selects the next row or SELECT statement in the query.
l NextRecord(). Moves the specified query to the next record.
l Previous(). Selects the previous row or SELECT statement in the query.
l SelectSql(). Executes SQL statements.
l BeginTrans(). Starts transaction for the following SQL statements.
l CommitTrans(). Commits a transaction initiated by BeginTrans().
l RollbackTrans(). Rolls back a transaction initiated by BeginTrans().
ExecSql()
Parameters
None
Examples
var sql;
sql = "UPDATE Company SET Comp_PrimaryUserID='"+AccountMgr+"' WHERE "+"
Comp_CompanyId="+Values('Comp_CompanyId');
CRM.ExecSql(sql);
Next()
Parameters
None
Examples
var Query;
Query = CRM.CreateQueryObj("Select * from company", "");
Query.SelectSql();
while (!Query.eof)
{
CRM.AddContent(Query("comp_companyid") + " = " + Query("comp_name") + "
");
Query.Next();
}
Response.Write(CRM.GetPage());
Returns the next row in the query that displays company identifiers and names.
NextRecord()
Parameters
None
Examples
Query.NextRecord();
Previous()
Parameters
None
Examples
Query.Previous();
Executes SQL statements.
Use this method to execute statements that return rows (SELECT statements).
Parameters
None
Examples
var Query;
Query = CRM.CreateQueryObj("Select * from company", "");
Query.SelectSql();
while (!Query.eof)
{
CRM.AddContent(Query("comp_companyid") + " = " + Query("comp_name")+" ");
Query.NextRecord();
}
Response.Write(CRM.GetPage());
Displays the company identifier and name field from the selected SQL query until the end of the query.
BeginTrans()
Parameters
None
Examples
var updatequery;
updatequery = CRM.CreateQueryObj(sql);
try
{
updatequery.BeginTrans();
updatequery.ExecSql();
updatequery.CommitTrans();
}
catch(ex)
CommitTrans()
Parameters
None
Example
var updatequery;
updatequery = CRM.CreateQueryObj(sql);
try
{
updatequery.BeginTrans();
updatequery.ExecSql();
updatequery.CommitTrans();
}
catch(ex)
{
updatequery.RollbackTrans();
}
RollbackTrans()
Parameters
None
var updatequery;
updatequery = CRM.CreateQueryObj(sql);
try
{
updatequery.BeginTrans();
updatequery.ExecSql();
updatequery.CommitTrans();
}
catch(ex)
{
updatequery.RollbackTrans();
}
CRMQuery properties
l Bof. Indicates the beginning of query.
l DatabaseName. Specifies a database other than the default system database.
l Eof. Indicates the last row of query.
l FieldValue. Gets or sets individual fields in a query.
l RecordCount. Gets the number of records referred to by the CRMQuery object.
l SQL. Sets the SQL statement for the query.
Bof
Example
var comp;
comp = CRM.CreateQueryObj('select * from Company where Comp_
CompanyId=12');
comp.SelectSql();
if ((!comp.eof) && (!comp.bof))
{
CRM.AddContent(comp.comp_name);
}
else
{
CRM.AddContent('Company does not exist');
}
Response.Write(CRM.GetPage());
Parameters
Name. Specifies the database name. This parameter accepts a string value.
Examples
var Query;
Query = CRM.CreateQueryObj('Select * from company', 'crm');
Query.SelectSQL();
Query.DatabaseName(crm);
Eof
Example
var Query;
Query = CRM.CreateQueryObj("Select * from vCompany");
Query.SelectSql();
while (!Query.eof)
{
Response.Write(Query("comp_companyid") + " = " + Query("comp_name")+' ');
Query.NextRecord();
}
Displays the company identifiers and name fields from the selected SQL query until the end of the query.
FieldValue
Parameters
Examples
var value;
value = Query.FieldValue("MyField");
Displays the company identifier and the name field from the selected SQL query.
RecordCount
Parameters
None
Examples
var Query;
Query = CRM.CreateQueryObj("Select * from company");
Query.SelectSQL();
CRM.AddContent("There are " +Query.RecordCount+ " records.");
Response.Write(CRM.GetPage());
Displays a record count of all records in the Company table of the default database.
SQL
Examples
var Query;
Query = CRM.CreateQueryObj("Select * from company", "");
Query.SQL = "Select * FROM person";
Query.SelectSql();
Resets the SQL SELECT statement to query the Person table instead of the Company table.
l CRMRecord methods
l CRMRecord properties
CRMRecord methods
l FirstRecord(). Moves the record to point to the first record that matches the SQL passed in when the
Record object was created.
l NextRecord(). Returns the next record, if any.
l RecordLock. Locks the current Record object.
l SaveChanges(). Saves changes made to the current record to the database.
l SaveChangesNoTLS(). Saves changes made to the current record in the database. Does not trigger
any table-level scripts that exist for the table being updated.
l SetWorkflowInfo(vWorkflowName, vWorkflowState). Saves a new record to a workflow.
FirstRecord()
Moves the record to point to the first record that matches the SQL passed in when the Record object was
created.
When the Record object is created, it automatically points to the first record. Use this method to set it.
Example
var o;
o = CRM.FindRecord("company","comp_name like 'o%'");
while (!o.eof)
{
Finds companies whose names start with the letter o and displays the first company record.
NextRecord()
Examples
var People;
People = CRM.FindRecord('Person','Pers_Deleted is null');
while (!People.Eof)
{
CRM.AddContent(People.Pers_FirstName+' '+People.Pers_LastName+'');
People.NextRecord();
}
Response.Write(CRM.GetPage());
Displays a list of first and last names of people in the Person table.
RecordLock
Parameters
None
var r;
r = CRM.FindRecord('company','comp_companyid=30');
CompBlock = CRM.GetBlock('CompanyBoxLong');
CompBlock.CheckLocks = false;
if (CRM.Mode == 1)
{
e = r.RecordLock();
if (e != '')
{
CRM.Mode = 0;
// Keep in view mode.
CRM.AddContent(e+'');
}
}
CRM.AddContent(CompBlock.Execute(r));
Response.Write(CRM.GetPage());
Locks the record. If the record is already locked, displays an error message and places the record in view
mode.
SaveChanges()
Examples
var Comp;
var block;
Comp = CRM.CreateRecord('company');
Comp.item('comp_Name') = '4D Communications International';
Comp.SaveChanges();
block = CRM.GetBlock("companygrid");
CRM.AddContent(block.execute(''));
Response.Write(CRM.GetPage());
Adds and saves a new record to the company table and displays in a list.
var companies;
var company;
companies = CRM.FindRecord("company","comp_name like 'Gate%'");
while (!companies.eof)
{
Response.Write(companies('comp_name')+'') ;
Response.Flush();
SaveChangesNoTLS()
Saves changes made to the current record in the database. Does not trigger any table-level scripts that exist
for the table being updated.
Example
var Comp;
var block;
Comp = CRM.CreateRecord('company');
Comp.item('comp_Name') = '4D Communications International';
Comp.SaveChangesNoTLS();
block = CRM.GetBlock("companygrid");
CRM.AddContent(block.execute(''));
Response.Write(CRM.GetPage());
Adds and saves a new record to the company table. Does not trigger the company table-level script.
SetWorkflowInfo(vWorkflowName, vWorkflowState)
Parameters
l vWorkflowName. Specifies a description of the workflow to which the record is saved. This is the
workflow description entered when the workflow was created.
l vWorkflowState. Specifies the state in the workflow in which the record is to be saved. This is the
State Name value entered when the workflow state was created.
Examples
Creates a new opportunity, saves it to the SalesOpportunityWorkflow, and assigns "In Progress" state to the
opportunity. When the opportunity is viewed, the valid actions for the assigned state are available.
CRMRecord properties
l DeleteRecord. Marks a record for deletion.
l Eof Indicates whether the last record has been reached.
l IdField. Returns the name of the ID field (also known as primary key) for the current table of the
CRMRecord object.
l Item. Gets or sets the field value in its native format.
l ItemAsString. Gets the field value as a string.
l OrderBy. Specifies the field name by which to order record objects.
l RecordCount. Gets the number of records referred to by the object.
l RecordID. Gets the unique ID of the current record.
DeleteRecord
Values
l true. Marks the record for deletion. The deletion occurs when the SaveChanges() method is called.
l false. Specifies that the record will not be deleted when the SaveChanges() method is called.
Examples
var Comp;
Comp = CRM.FindRecord('company', "comp_name = 'Eurolandia'");
Comp.DeleteRecord = true;
Comp.SaveChanges();
Return values
l true. Indicates that the last record has been reached or there are no records.
l false. Indicates that the last record hasn't been reached yet.
Examples
IdField
Returns the name of the ID field (also known as primary key) for the current table of the CRMRecord object.
Normally, this is the first field name in the table.
Example
var Comp;
var idname;
Comp = CRM.FindRecord('company', "comp_name = 'Design Right Inc.'");
idname = Comp.IdField;
CRM.AddContent(Comp.item(idname));
Response.Write(CRM.GetPage());
Item
Parameters
FieldName. Specifies the name of the field to get or set as the column in the table.
Example
record.Item("item");
record("item");
Creates a new record in the Company table, names the company "3D Communications International", and
displays it in a company list.
ItemAsString
Parameters
Examples
var Case;
Case = CRM.FindRecord('cases', "case_assigneduserid=5");
CRM.AddContent(Case.itemasstring("case_assigneduserid"));
Response.Write(CRM.GetPage());
Finds and displays the name of the user assigned to a case from userid.
OrderBy
Examples
var People;
People = CRM.FindRecord('Person','Pers_Deleted is null');
People.OrderBy = 'Pers_LastName, Pers_FirstName';
while (!People.Eof)
{
CRM.AddContent(People.Pers_FirstName+' '+People.Pers_LastName+'');
People.NextRecord();
Response.Write(CRM.GetPage());
}
RecordCount
Gets the number of records referred to by the object. This property returns an integer value.
Examples
var Users;
Users = CRM.FindRecord('users','');
CRM.AddContent("There are " +Users.RecordCount+ " system users.");
Response.Write(CRM.GetPage());
RecordID
Gets the unique ID of the current record. The unique ID is created automatically when the record is created.
Examples
Response.Write(Record.RecordID);
l CRMSelfService methods
l CRMSelfService properties
CRMSelfService methods
l EndSSSession(QueryString, ContentString, Cookie). Terminates the Self Service session and
resets the Sage CRM cookies.
l Init(QueryString, ContentString, Cookie). Initializes the Self Service session and Sage CRM cookies.
Terminates the Self Service session and resets the Sage CRM cookies.
Parameters
Terminates the Self Service session, resets Sage CRM cookies, and displays a log out message to the user.
Parameters
Examples
var CRM;
CRM = Server.CreateObject("eWare.eWareSelfService");
CRM.init(Request.Querystring,Request.Form,Request.Cookies("CRM"));
Response.Expires = -1;
CRMSelfService properties
l Authenticated. Gets a value indicating whether the current user is authenticated.
l AuthenticationError. Sets an authentication error to display.
l VisitorInfo. Gets or sets the value associated with a key for the current authenticated visitor.
Authenticated
None
Return value
Examples
if (CRM.Authenticated)
{
// This could be any function.
getmembermenu();
}
else
{
Response.Redirect("index.asp");
}
Allows an authenticated user to access a member menu. Takes unauthenticated users back to an index
page.
AuthenticationError
Parameters
None
Examples
if (CRM.Authenticated)
{
// Perform action for authenticated users
}
else
{
Response.Write('You are not a valid user' + CRM.AuthenticationError);
}
VisitorInfo
Gets or sets the value associated with a key for the current authenticated visitor.
The key can be a column on the visitor table beginning with "Visi", or any text.
Examples
if((CRM.Authenticated)&&(CRM.VisitorInfo("Visi_
NotificationCriteria")!=""))
{
// This could be any method.
getmembermenu();
};
Grants access to any authenticated visitor who has submitted any notification criteria.
l CRMTargetLists methods
l CRMTargetLists properties
l Example: Creating and saving a Target list
l Example: Retrieving a Target list
CRMTargetLists methods
l Save(). Saves the Target list.
l Include(ATargetID). Includes a target in the Target list.
l Exclude(ATargetID). Excludes a target from the Target list.
l Retrieve(). Retrieves a target from the Target list.
Save()
Parameters
None
Examples
Include(ATargetID)
None
Examples
Exclude(ATargetID)
Parameters
ATargetID. Specifies the ID of the target to exclude. This parameter accepts an integer value.
Examples
Retrieve()
Parameters
None
Examples
CRMTargetLists properties
l Category. Specifies the category of the Target list.
l Description. Specifies the description of the Target list.
Category
Values
String
Examples
Description
Values
String
Examples
Fields
Examples
GroupAccessLevel
Specifies who can access the Target list. This property is applicable only if the Target list is a group; for more
information, see IsNewGroupFromFind
Values
l <a positive integer>. Specifies the ID of the user who can access the group.
l 0. Specifies that all users, info managers, and system administrators can access the group.
l -1. Specifies that only info managers and system administrators can access the group.
Examples
IsFixedGroup
Specifies whether the Target list is a fixed group or a dynamic group. This property is applicable only if the
Target list is a group; for more information, see IsNewGroupFromFind
Values
Examples
IsNewGroupFromFind
Specifies whether the Target list is a group or a saved search from Find.
Examples
Name
Values
String
Examples
OrderByFields
Value
Examples
TargetListID
Integer
Examples
ViewName
Values
String
Examples
WhereClause
Values
String
Examples
l CRMTargetListField properties
CRMTargetListField properties
DataField. Specifies the name of the field to display on the Target list.
DataField
Values
String
Examples
l CRMTargetListFields methods
l CRMTargetListFields properties
CRMTargetListFields methods
l New(CRMTargetListField). Creates and returns a new field.
l Delete(Index). Deletes the specified field.
New(CRMTargetListField)
Values
CRMTargetListField object
Examples
Delete(Index)
Values
Parent
Value
Examples
Count
Values
Integer (read-only)
Examples
Item
Values
For more information about E-mail Management, see the System Administrator Help.
l Email methods
l Email object properties
Email methods
l Send(). Sends an email using the contents of the Email object.
l AddFile(Value). Adds a file as an attachment to the Email object.
l Clear(). Clears the contents of the Email object.
l Header(Value). Returns any named header value from the email.
Send()
Parameters
None
Examples
email.Send();
AddFile(Value)
Parameters
Examples
email.AddFile('C:\MyFolder\MyWordFile.docx');
Clear()
Clears the contents of the Email object. Typically use this before you want to send a new email.
Parameters
None
Examples
email.Clear();
Header(Value)
Returns any named header value from the email. Returns a blank string if the header value does not exist.
Parameters
Examples
comm("comm_replyto") = email.Header("Reply_To");
Body
Values
String
Examples
comm("Comm_Email") = eMail.Body
IsHTML
Values
Examples
eMail.IsHTML = true;
Subject
Values
String
Examples
comm("Comm_Note") = eMail.Subject;
Priority
l 0. Low priority.
l 1. Normal priority.
l 2. High priority.
Examples
var prHigh;
phHigh = 2;
eMail.Priority = prHigh;
Recipients
Values
AddressList object
Examples
var MyAddressList;
var singleaddress;
MyAddressList = email.Recipients;
// Get the first email address from the list.
singleaddress = MyAddressList.Items(0).Address;
SenderName
Values
String
Examples
Values
String
Examples
DeliveryTime
Specifies the time and date when the email message was delivered to the inbox.
Values
None
Examples
var commdate;
commdate = new Date(eMail.DeliveryTime);
comm("Comm_datetime") = commdate.getVarDate();
Attachments
Values
AttachmentList object
Examples
var myAttachments;
myAttachments = email.Attachments;
var myAttachment;
myAttachment = eMail.Attachments.Items(1);
BCC
Gets the email addresses in the BCC field of the email message.
AttachmentList object
Examples
var singleaddress;
singleaddress = email.BCC.Items(0).Address;
CC
Values
AttachmentList object
Examples
var singleaddress;
singleaddress = email.CC.Items(0).Address;
For more information about E-mail Management, see the System Administrator Guide or Help.
l MailAddress properties
MailAddress properties
l Name. Gets or sets the user-friendly name associated with the email address.
l Address. Gets or sets the email address.
Name
Gets or sets the user-friendly name associated with the email address.
Values
String
Examples
var FromName;
FromName = eMail.CC.Items(1).Name;
Address
Values
String
Examples
var FromAddress;
FromAddress = eMail.CC.Items(1).Address;
l MsgHandler methods
l MsgHandler properties
MsgHandler methods
l Log(value). Sets the message to write to a log file in the Sage CRM installation folder.
l MailAdmin(Subject, Body). Sends an email to the system administrator.
l GetUniqueFileName(Path, FileName). Checks if the specified file exists.
Log(value)
Sets the message to write to a log file in the Sage CRM installation folder. This method is only available
when the Debug property is set to true.
Parameters
Examples
MsgHandler.Debug = true;
MsgHandler.Log("testing application");
MailAdmin(Subject, Body)
Sends an email to the system administrator. This method uses the email address specified in the EmSe_
AdminAddress in the custom_emailaddress table.
Parameters
l Subject. Specifies the email message subject. This parameter accepts a string value.
l Body. Specifies the email message body text. This parameter accepts a string value.
var sSubject;
var Body;
sSubject = "Unknown customer";
sBody = "An unknown customer attempted to mail the service";
MsgHandler.MailAdmin(sSubject,sBody);
GetUniqueFileName(Path, FileName)
Return value
If the file exists, this method returns the name of the file.
If the file does not exist, this method returns the next valid name for the file.
Parameters
Examples
var NewName;
NewName = MsgHandler.GetUniqueFileName(libdir, AttItem.Name);
AttItem.SaveAs(NewName, libdir);
MsgHandler properties
l Msg. Returns the Email object.
l Debug. Sets whether to write messages sent via the Log(value) method to the log file.
l EmailAddress. Gets the email address of the service.
Msg
Returns the Email object. Do not access this parameter from the script, as it's already been passed in as the
Email object.
Values
Email object
var myemail;
myemail = MsgHandler.msg;
Debug
Sets whether to write messages sent via the Log(value) method to the log file.
Values
Examples
MsgHandler.Debug = true;
EmailAddress
Values
String
Examples
var serviceaddress;
serviceaddress = MsgHandler.EmailAddress;
l Add methods
l Copy methods
l Create methods
l Delete and Drop methods
l Get methods
l SearchAndReplace methods
l Other methods
AddCoachingCaptions method
Adds a new coaching caption.
Return value
AddColumn method
Adds a column to an existing table.
Parameters
l Col_TableName. Specifies the name of the table to which the column is to be added.
l Col_ColumnName. Specifies the column name.
l Col_Type. Specifies the entry type for the column.
l Col_Size. Specifies the column size (in characters) for certain field types, for example, text fields.
l Col_AllowNulls. Specifies if the column can take null values. Can take one of the following values:
l True. The column can take null values.
l False. The column doesn't accept null values.
l Col_IsUnique. Specifies if the values in the column must be unique. Can take one of the following
values:
l True Values in the column must be unique.
l False. Values in the column do not have to be unique.
l Col_IsIdentity. Indicates whether the column should be created as an auto-incrementing field.
Boolean.
Return value
None
AddCustom_Captions method
Adds or modifies translations in Sage CRM.
Parameters
l Capt_FamilyType. Specifies the family type to which the caption belongs. For example, Tags.
l Capt_Family. Specifies the family for the caption.
Return value
AddCustom_ContainerItems method
Adds blocks to a container.
Parameters
Return value
AddCustom_Data method
Adds or updates data in the specified database table.
Note that this method may not work to update certain custom tables, because updates to the foreign key are
not set automatically. The affected custom tables include Custom_Edits, Custom_Views, Custom_
ScreenObjects, Custom_List, Custom_ContainerItems, Custom_Tabs, and Custom_Screen.
l TableName. Specifies the name of the table in which you want to add or update data.
l TablePrefix. Specifies the table prefix.
l IdColumn. Specifies the name of the table column that holds the ID.
l Fields. Specifies the fields to update. When specifying multiple fields, use a comma as a separator.
l Values. Specifies the values to assign to the fields. When specifying multiple values, use a comma as
a separator. The list of values must match the list of fields provided in the Fields parameter. To insert
the value into a string field, surround the value with double quotes.
You can use the following variables in place of actual values:
l ISBLANK. Inserts a blank space into a text field (identical to setting the value to "").
l ISNULL. Marks column as NULL.
l ISNOW. Inserts the current date and time up to the nearest second.
l KeyFields. Specifies the fields in the Fields parameter whose values you want to use to uniquely
identify records. If a record with the specified ID exists, it will be updated. Otherwise, the record will
be created.
To specify a field, enter the index the field has in the Fields parameter. When specifying multiple
fields, use a comma as a separator.
Return value
None
Example
AddCustom_Data('Custom_Captions', 'Capt', 'Capt_CaptionId', 'Capt_
FamilyType,Capt_Family,Capt_Code,Capt_DU,CreatedDate',
'"Tags","ColNames","Comp_Name","Company",ISNOW', '1,2,3');
AddCustom_Databases method
Adds links to external databases.
Parameters
Return value
AddCustom_Edits method
Adds or modifies the properties of an entity field.
Parameters
Return value
Parameters
l GriP_GridNam. Specifies the name of the grid into which to add the column.
l GriP_Order. Specifies the order in which the column appears in the grid.
l GriP_ColName. Specifies the column name.
l GriP_AllowRemove. Specifies if the column is removable. This parameter can take one of the
following values:
l Y. The column is removable.
l N. The column is not removable.
l GriP_AllowOrderBy. Specifies if the column can be used to order the list. This parameter can take
one of the following values:
l Y. The column can order the list.
l N. The column cannot order the list.
l GriP_OrderByDesc. Sets the default sort mode for ordering items in the column.
l Y. The default mode is descending.
l N. The default mode is ascending.
l GriP_Alignment. Sets the alignment for the text in the column. This parameter can take one of the
following values:
l CENTER (or NULL). Center text.
l LEFT. Align text to the left.
l RIGHT. Align text to the right.
l GriP_Jump. Specifies if the column can contain a hyperlink to another page.
l GriP_ShowHeading. Specifies if the column heading is displayed in the list. This parameter can
take one of the following values:
l Y. Shows the column heading in the list.
l N. Hides the column heading in the list.
l GriP_ShowSelectAsGif. Specifies if this column should show as a GIF. This parameter can take
one of the following values:
l Y. Shows the column as a GIF.
l N (or NULL). Doesn't show the column as a GIF.
l GriP_CustomAction. Specifies the name of page to hyperlink to if the GriP_Jump parameter is set
to Custom.
l GriP_CustomIdField. Specifies the name of field to use as the ID field if the GriP_Jump is set to
Custom.
l GriP_DeviceID. Specifies the device ID of the list. The device ID is taken from the Devices table.
l Grip_CreateScript. Allows you to enter a create script for a column. The default value is blank.
AddCustom_Relationship method
Add entity relationships for SData provider.
Parameters
l TableName. String.
l ColumnName. String.
l TableNameRelated. String.
l ColumnNameRelated. String.
l RelationshipType. Integer.
l IsCollection. Boolean.
l LinkTableName. String.
l LinkColumnName. String.
l LinkColumnNameRelated. String.
Return value
AddCustom_Report method
Creates a report.
Parameters
l Repo_Category. String.
l Repo_Name. String.
l Repo_Title. String.
l Repo_Description. String.
l Repo_Bands. Integer.
l Repo_ExportAsXML. String.
l Repo_FooterCentrePageData. String.
l Repo_FooterLeftPageData. String.
l Repo_FooterRightPageData. String.
l Repo_HeaderCentrePageData. String.
Return value
AddCustom_ReportBand method
Adds a report band.
Parameter
l ReBa_ReportID. Integer.
l ReBa_DetailLevel. Integer.
l ReBa_CrossTabField. String.
l ReBa_DisplayOptions. Integer.
l ReBa_ViewName. String.
l ReBa_WhereClause. String.
l ReBa_DetailLinkField. String.
l ReBa_MasterLinkField. String.
Return value
AddCustom_ReportChart method
Adds a chart to a report.
l ReCh_ReportID. Integer.
l ReCh_Options. Integer.
l ReCh_BackImageName. String.
l ReCh_BarStyle. String.
l ReCh_BottomCaption. String.
l ReCh_BottomDateFunction. String.
l ReCh_BottomFieldName. String.
l ReCh_Elevation. Integer.
l ReCh_GradientEndColour. String.
l ReCh_GradientStartColour. String.
l ReCh_Height. Integer.
l ReCh_HorizontalOffset. Integer.
l ReCh_LeftCaption. String.
l ReCh_LeftFieldName. String.
l ReCh_LeftFunction. String.
l ReCh_LegendAlignment. String.
l ReCh_MarksStyle. String.
l ReCh_Perspective. Integer.
l ReCh_PieRotation. Integer.
l ReCh_Rotation. Integer.
l ReCh_Style. String.
l ReCh_Tilt. Integer.
l ReCh_VerticalOffset. Integer.
l ReCh_Width. Integer.
l ReCh_Zoom. Integer
Return value
AddCustom_ReportField method
Adds a report field.
l ReFi_ReportBandID. Integer.
l ReFi_Alignment. String.
l ReFi_DataField. String.
l ReFi_UsageType. String.
l ReFi_DisplayOrder. Integer.
l ReFi_JumpDestination. String.
l ReFi_JumpFileName. String.
l ReFi_JumpIdentifier. String.
l ReFi_Mask. String.
l ReFi_TotalsType. String.
l ReFi_SortOrder. Integer.
Return value
AddCustom_ReportGroup method
Adds a report group.
Parameters
l ReGr_ReportBandID. Integer.
l ReGr_GroupByField. String.
l ReGr_GroupOrder. Integer.
l ReGr_HasFooter. String.
l ReGr_JumpDestination. String.
l ReGr_JumpFileName. String.
l ReGr_JumpIdentifier. String.
Return value
AddCustom_ScreenObjects method
Adds a new custom screen object, such as list, screen, search screen, tab group, filter box, or block.
l CObj_Name. Specifies the name of the custom screen object. This name must be unique.
l CObj_Type. Specifies the type of the custom object. This parameter can take one of the following
values:
l List
l Screen
l SearchScreen
l TabGroup
l FilterBox
l Block
l CObj_EntityName. Specifies the name of the entity on which the custom object is based.
l CObj_AllowDelete. Specifies if a user can delete the custom object. This parameter can take one of
the following values:
l Y. A user can delete the custom object.
l N. A user cannot delete the custom object.
l CObj_Deleted. Specifies if the custom object is deleted. This parameter can take one of the
following values:
l 0. The custom object is not deleted.
l 1. The custom object is deleted.
l CObj_TargetTable. Specifies the table from which fields can be added to the custom object.
l CObj_Properties. Internal use only. Specifies the list of properties the custom object has. When
specifying multiple properties use a comma as a separator.
l CObj_CustomContent. Allows you to enter a custom script for the custom object.
l CObj_UseEntity. Specifies the table from which fields can be added to the custom object.
l CObj_TargetList. Internal use only.
l CObj_Ftable. Internal use only.
l CObj_FtableFCol. Internal use only.
l CObj_CheckNameOnly. Optional. Specifies how to check the custom object during update
operations. This parameter can take one of the following values:
l TRUE. Allows object updates by checking the object name only.
l FALSE. Specifies that object name and entity are checked during object updates.
Return value
AddCustom_Screens method
Adds or modifies a field on a screen.
l SeaP_SearchBoxName. Specifies the name of the screen where you want to add or modify the
field. This should match the Cobj_Name value specified in the Custom_ScreenObjects table.
l SeaP_Order. Specifies the order in which the field appears on the screen.
l SeaP_ColName. Specifies the column name of the field.
l SeaP_Newline. Specifies if the field should appear on a new line. This parameter can take one of the
following values:
l 1. The field appears on a new line.
l 0. The field appears on the same line.
l SeaP_RowSpan. Specifies the number of rows that the field should span on the screen.
l SeaP_ColSpan. Specifies the number of columns that the field should span on the screen.
l SeaP_Required. Specifies if the field is required.
l Y. The field is required.
l N. The field is optional.
l SeaP_DeviceID. Specifies the ID of the device that this screen is for. Look up from the Devices
table.
l SeaP_OnChangeScript. Allows you to enter the client-side JavaScript to apply to the OnChange
event of the field.
l SeaP_ValidateScript. Specifies the server-side script to run to validate the field.
l SeaP_CreatedScript. Specifies the server-side script to run when the field is created.
l SeaP_Jump. Specifies the location to open when the field is clicked.
Return value
Example
To add fields on a screen, you can also use the AddEntryScreenField method.
In the examples below, the AddCustom_Screens and AddEntryScreenField methods add the same
fields.
AddCustom_Screens EntryScreenName=
('GlobalLibraryFilterBox',1, 'GlobalLibraryFilterBox';
'libr_filename',0,1,1,'N',0, FieldOrder=1;
'','','',''); FieldName='libr_filename';
NewLine=false;
RowSpan=1;
ColSpan=1;
Required=false;
AddEntryScreenField();
AddCustom_Scripts method
Adds a table- or entity-level script.
Parameters
l CScr_TableName. Specifies the name of the table to which the script applies.
l CScr_ScriptName. Specifies the script name.
l CScr_Order. Specifies the order in which this script should be run, if there are more than one script
on a table.
l CScr_Script. The actual script.
l CScr_ScriptUser. Specifies the user name under which to run the script, if applicable.
l CScr_ScriptType. Specifies the script type. This parameter can take one of the following values:
l entity. Specifies that the script is entity-level.
l entitywrb. Specifies that the script is entity-level with rollback.
l tls. Specifies that the script is table-level.
l tlsdetached. Specifies that the script is detached table-level.
l CScr_UseRollBack. Specifies if rollback is available on the script. This parameter can take one of
the following values:
l Y. Rollback is available.
l N. Rollback is not available.
l CScr_ViewName. Specifies the name of the view from which the script gets information.
Note that the CScr_IsEntityScript parameter of this method has been deprecated. Please use the
CScr_ScriptType parameter instead.
Return value
Parameters
Return value
AddCustom_Tabs method
Adds or modifies a tab in a tab group.
Return value
AddLPCategory method
Adds a dashboard category.
Parameters
AddLPGadget method
Adds a dashboard gadget.
Parameters
Return value
AddLPLayout method
Adds a dashboard.
Parameters
Return value
AddLPUserLayout method
Assigns a dashboard template to a user.
Parameters
Return value
AddMessage method
Sets the message to show to a user while the component is being installed.
Parameters
AddProduct method
Adds a product.
Parameters
l Prod_Name. String.
l Prod_Description. String.
l Prod_ListPrice. String.
l Prod_Image. String.
l Prod_APR. String.
Return value
AddView method
Adds a view.
Parameters
Return value
CopyAndDropColumn method
Modifies the properties of a column.
This method creates a new column, copies data from the source column to that new column, updates the
new column properties according to the specified parameters, deletes the source column, and then assigns
the name of the source column to the new column.
Parameters
l Col_TableName. Specifies the name of the table that contains the column to be modified.
l Col_ColumnName. Specifies the column name.
l Col_Type. Specifies the new data type of the column.
l Col_Size. Specifies the new size of the column.
l Col_Allow_Nuls. Specifies whether the column allows null values.
Return value
None
CopyAspTo method
Copies an ASP file from one location to another. Relative paths are allowed in the parameters of this
method.
Parameters
l CTo_FileName. Specifies the source file path and name (copy from).
l CTo_NewFileName. Specifies the target file path and name (copy to).
Return value
CopyFile method
Copies a file from one location to the other.
Parameters
Return value
None
CreateNewDir method
Creates a new directory.
Parameters
Return value
None
CreateTable method
Creates a table in the database.
Created table has the following standard Sage CRM fields: CreatedBy, CreatedDate, UpdatedBy,
UpdatedDate, TimeStamp, and Deleted.
Parameters
Return value
DeleteColumn method
Deletes the specified table column.
Parameters
l TableName. Specifies the name of the table that includes the column to be deleted.
l ColumnName. Specifies the column name.
To delete table columns, we recommend that you use the DeleteCustom_Field method.
Return value
None
DeleteCustom_Caption method
Deletes the specified caption.
Parameters
Return value
None
Parameters
Return value
None
DeleteCustom_Field method
Deletes the specified field from the system.
Deleting a field by using this method removes the field from all screens, lists, reports, saved searches,
notifications and other locations in the system.
Parameters
l ATableName.
l AColumnName.
Return value
None
DeleteCustom_Screen method
Deletes the specified screen.
This method deletes all items for the specified screen regardless of device.
Parameters
Return value
Parameters
l CObj_Name. Specifies the name of the Custom_ScreenObject for which you want to delete data.
l DeleteHeader. Specifies whether to delete the Custom_ScreenObject record from the Custom_
ScreenObjects table. This parameter can take one of the following values:
l True. Specifies to delete the object record in the Custom_ScreenObjects table.
l False. Keeps the object record in the Custom_ScreenObjects table, but deletes subitems
from Custom_Lists, Custom_Screens, and Custom_ContainerItems.
l CObj_DeviceID. Specifies the device records to delete. This parameter can take one of the
following values:
l <DeviceID>. Specifies the ID of the device whose records are to be deleted.
l 0. Specifies to delete all records for every device.
l 1. Specifies to delete desktop information only.
Return value
DropConstraint method
Deletes the specified constraint from a table in the database, such as foreign key.
Parameters
l AConstraintName. Specifies the name of the constraint to delete from the database.
l ATableName. Specifies the name of the table that contains the constraint.
Return value
DropTable method
Deletes the specified table from the database.
Parameters
DropView method
Deletes the specified view from the database.
Parameters
Return value
GetDLLDir method
Returns the full path to the eware.dll file.
Parameters
None
Return value
GetInstallDir method
Returns the path to the Sage CRM installation folder.
Parameters
None
Return value
Example
var x = GetInstallDir();
Gets the path to the Sage CRM installation folder and stores it in the x variable.
Param method
Returns the value of the specified parameter.
Return value
Parameter value.
SearchAndReplaceCustomFile method
Finds and replaces text in the specified file.
Parameters
l Sr_FileName. Specifies the full path and name of the target file.
l Sr_StringToSearch. Specifies the text to search for and replace.
l Sr_ReplaceString. Specifies the replacement text.
Return value
SearchAndReplaceInDir method
Finds and replaces text in all files located in the specified folder.
Parameters
l ADirPath. Specifies the full path and name of the target folder.
l AStringToSearch. Specifies the text to search for and replace.
l AReplaceString. Specifies the replacement text.
Return value
SearchAndReplaceInFile method
Finds and replaces text in the specified file located in <Sage CRM installation folder>\CustomPages.
Return value
FinishLandingPage method
Replaces all the markers in layoutXml with new IDs collected during creation of dashboards and gadgets.
Make sure to run this method after running any other interactive dashboard methods.
The interactive dashboard methods should be run in the following order:
1. AddLPCategory
2. AddLPLayout
3. AddLPGadget
4. AddLPUserLayout
5. FinishLandingPage
Return value
FileOpen method
Returns values stored in the specified comma-separated values (.csv) or Microsoft Excel file.
Parameters
AFileName. Specifies the full path and name of the .csv or Microsoft Excel file.
Return value
Returns the DataFile object that can be used to process the values in the file. The DataFile object has the
following properties:
l NextRow. Skips the file pointer on to the next row in the file. This method does not have any
parameters.
l GetField. Returns the value in the given field for the current row.
This method has the AIndex parameter, which indicates the column number to return the value for.
When the AIndex is set to 0, it returns the value in the first column of the current row, and so on.
ProgressScriptTransaction method
Commits to the database what has already been processed and starts a new transaction.
Parameters
ComminOnError. This optional parameter commits database transactions even if an error has occurred.
Return value
None
QueryResultsToFile method
Runs the specified SQL select statement and writes its result to a comma-separated values (.csv) file on the
Sage CRM server.
Parameters
l FileName. Specifies the full path and name of the .csv file to write to.
l QueryString. Specifies the SQL select statement.
Return value
Example
QueryResultsToFile("c:\\test.csv","SELECT capt_family, capt_code,capt_fr
FROM custom_captions ORDER BY capt_family, capt_order");
Parameters
Return value
None
TableExists method
Checks whether the specified table exists in custom_table.
Parameters
Return value