DP09: Using the API Objects in ASP Pages (Part 1 of 2)

advertisement
Sage CRM Developers Course
Using the API
Objects in ASP
Pages (1)
Looking ahead to the classes
DP01: Introduction to the Development
Partner Program
DP02: Entities and the Data Model (Part 1 of
2)
DP03: Entities and the Data Model (Part 2 of
2)
DP04: Implementing Screen Based Rules
(Part 1 of 2)
DP05: Implementing Screen Based Rules
(Part 2 of 2)
DP06: Screen and User Independent
Business Rules
DP07: Workflow (Part 1 of 2)
DP08: Workflow (Part 2 of 2)
DP09: Using the API Objects in ASP Pages
(Part 1 of 2)
DP10 : Using the API Objects in ASP Pages
(Part 2 of 2)
DP11: Using the Component Manager
DP12: Programming for the Advanced Email
Manager
DP13: Using the Web Services API
DP14: Using the Web Services API (Part 2 of
2)
DP15: Coding the Web Self Service COM API
(Part 1 of 2)
DP16: Coding the Web Self Service COM API
(Part 2 of 2)
DP17: Using the .NET API (Part 1 of 2)
DP18: Using the .NET API (Part 2 of 2)
Agenda
Using the API objects in ASP Pages
Linking to External Databases
Extending the Data Model
Basic Data Handling within an ASP Page
Listing Data
Editing Data
Adding Data
Creating a Page
Standard include files
sagecrm.js
reference in JavaScript-based ASP pages. This file sets the default language to JavaScript.
(Default for Sage CRM v7.x)
sagecrmnolang.js
this file does not set the default language. (Default for Sage CRM v7.x)
accpaccrm.js
reference in JavaScript-based ASP pages. This file sets the default language to JavaScript.
accpacnolang.js
this file does not set the default language.
ewaress.js
reference in JavaScript-based, Self Service ASP pages.
sagecrmnolang.js file
CRM = Server.CreateObject("eWare.CRM");
eMsg = CRM.Init(
Request.Querystring,
Request.Form,
Request.ServerVariables("HTTPS"),
Request.ServerVariables("SERVER_NAME"),
false,
Request.ServerVariables("HTTP_USER_AGENT"),
Accept);
Developer Include Files
Received when DP joins program.
sagecrmdpp.js
Sagecrmnolangdpp.js
sagecrmdpp.vbs
accpaccrmdpp.js
accpaccrmnolangdpp.js
accpaccrmdpp.vbs
Include the appropriate files in your third-party products/installs.
These files are supplied to CRM Development Partners only.
They will enable your product to run on the CRM installs that do not
have the Enterprise Integration Server (EIS).
Products using the standard accpaccrm.js will not run on systems
without EIS.
Connecting to an external Database
Making a permanent database connection
Making a 3rd Party table work like a CRM table
select * from custom_databases
New Entities
Full Customization of new
screens, lists and views
Full use of field and table level
scripts
Governed by Security Territories
Workflow can be built
Automatic System Policing of
insert by, update by and
timestamps
Available for reporting and target
lists
CREATE TABLE [dbo].[Project] (
[PROJ_ProjectId] [int] IDENTITY (1, 1) NOT NULL ,
[PROJ_PrimaryCompanyId] [int] NULL ,
[PROJ_PrimaryPersonId] [int] NULL ,
[PROJ_AssignedUserId] [int] NULL ,
[PROJ_ChannelId] [int] NULL ,
[PROJ_Description] [char] (40) NULL ,
[PROJ_CreatedBy] [int] NULL ,
[PROJ_CreatedDate] [datetime] NULL ,
[PROJ_UpdatedBy] [int] NULL ,
[PROJ_UpdatedDate] [datetime] NULL ,
[PROJ_TimeStamp] [datetime] NULL ,
[PROJ_Deleted] [tinyint] NULL ,
[PROJ_SegmentID] [int] NULL ,
[PROJ_SecTerr] [int] NULL ,
[PROJ_WorkflowId] [int] NULL
)
ASP Example Screenflow
New Entity Tasks
Create New Project Table
Must have core columns as discussed in
documentation
Link new project table to CRM.
Add additional columns to create
relationships
Create screens
–
–
–
–
entityWebPicker
entityDetailBox
entitySearchBox
entityTopContent
Create a view that will exclude deleted
entities.
e.g. select * from project where proj_deleted
is null
Create lists with appropriate
hyperlinks
entitylist
entitygrid
If list calls proj_status "selection as gif"
add folder and images
Create calls to asp pages from menus
Admin>Customization>System>find
Admin>Customisation>System>new
Create Tab bar for new entity(with same
name as entity)
Project
Create asp pages
projectnew.asp
projectsummary.asp
projectfind.asp
projectlist.asp
Create workflow
project workflow
Naming Conventions
Suggested Naming Convention for new
Entity Blocks
Screens
– entityWebPicker
– entityDetailBox
– entitySearchBox
– entityTopContent
Lists
– entityGrid
– entityList
ASP pages
entityFind.asp
entityNew.asp
entitySummary.asp
entityUser.asp
entityEntity.asp
– (for listing children of new entity from
entities tab bar)
Typical Tasks
Create a List Page
Create an Insert Page
Create an Edit Page
Handling deletes
Create a Search Page
List Page Structure
var myBlock = CRM.GetBlock('opportunitylist');
var myRecordId = CRM.GetContextInfo('company','comp_companyid');
var Arg = 'oppo_primarycompanyid='+myRecordId
CRM.AddContent(myBlock.Execute(Arg));
Response.Write(CRM.GetPage());
Edit Page Structure
var myBlock = CRM.GetBlock('OpportunityDetailBox');
var myRecordId = CRM.GetContextInfo('Opportunity','oppo_opportunityid');
//var myRecordId = Request.QueryString('oppo_opportunityid');
var myRecord = CRM.FindRecord('Opportunity','oppo_opportunityid='+myRecordId);
CRM.AddContent(myBlock.Execute(myRecord));
Response.Write(CRM.GetPage());
Adding Buttons
//Example to call an inbuilt CRM action e.g 130 is find company
var strFindCompanyButton = CRM.Button('search','search.gif', CRM.Url(130));
//Example to call a Custom ASP page
var strCallASPButton = CRM.Button('ASP','save.gif', CRM.Url('myPage.asp'));
//Example to show control of buttons display on screen using entity security
//The following button is only available for users with insert rights on company entity (see security)
var strNewCompanySecurityButton = CRM.Button('New','newcompany.gif', CRM.Url(1200),'COMPANY','INSERT');
//Example to show how to build a custom help button
var helpFile = "FI_SearchingForCompany.htm";
var strCustomHelpButton =CRM.Button("Help", "help.gif", "javascript:window.open('/"+sInstallName+"/help/EN/Main
Menu/Default_CSH.htm#User/"+helpFile+"', 'HELPWIN','scrollbars=yes,toolbar=no,menubar=no,resizable=yes,top=200,
width=600,height=400');");
re = /href/gi;
strCustomHelpButton = strCustomHelpButton.replace(re, "onclick");
myBlock.AddButton(strFindCompanyButton);
myBlock.AddButton(strCallASPButton);
myBlock.AddButton(strNewCompanySecurityButton);
myBlock.AddButton(strCustomHelpButton);
Add Page Structure
if(CRM.Mode ==View)
{
CRM.Mode = Edit;
}
var myBlock = CRM.GetBlock('opportunitydetailbox');
var myRecord = CRM.CreateRecord('Opportunity');
myRecord.oppo_stage= 'Lead';
myRecord.oppo_status= 'In Progress';
myRecord.oppo_primarycompanyid= CRM.GetContextInfo('Company','comp_companyid');
myRecord.oppo_primarypersonid= CRM.GetContextInfo('person','pers_personid');
CRM.AddContent(myBlock.Execute(myRecord));
Response.Write(CRM.GetPage());
if(CRM.Mode == Save)
{
Response.Redirect(CRM.URL('customoppolist.asp'))
}
Q&A
Looking ahead to the classes
DP01: Introduction to the Development
Partner Program
DP02: Entities and the Data Model (Part 1 of
2)
DP03: Entities and the Data Model (Part 2 of
2)
DP04: Implementing Screen Based Rules
(Part 1 of 2)
DP05: Implementing Screen Based Rules
(Part 2 of 2)
DP06: Screen and User Independent
Business Rules
DP07: Workflow (Part 1 of 2)
DP08: Workflow (Part 2 of 2)
DP09: Using the API Objects in ASP Pages
(Part 1 of 2)
DP10 : Using the API Objects in ASP Pages
(Part 2 of 2)
DP11: Using the Component Manager
DP12: Programming for the Advanced Email
Manager
DP13: Using the Web Services API
DP14: Using the Web Services API (Part 2 of
2)
DP15: Coding the Web Self Service COM API
(Part 1 of 2)
DP16: Coding the Web Self Service COM API
(Part 2 of 2)
DP17: Using the .NET API (Part 1 of 2)
DP18: Using the .NET API (Part 2 of 2)
Download