sage crm developers course

27
Sage CRM Developers Course Programming for the Advanced Email Manager

Upload: ilana

Post on 25-Feb-2016

67 views

Category:

Documents


4 download

DESCRIPTION

Sage CRM Developers Course. Programming for the Advanced Email Manager . 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) - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Sage CRM Developers Course

Sage CRM Developers Course

Programming for the Advanced Email Manager

Page 2: Sage CRM Developers Course

Looking ahead to the classes

DP01: Introduction to the Development Partner ProgramDP02: 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 RulesDP07: 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 ManagerDP12: Programming for the Advanced Email ManagerDP13: Using the Web Services APIDP14: 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)

Page 3: Sage CRM Developers Course

Agenda

How the Email Manager works and processes emails.Creating a template Calling new functionsProcessing dataOpportunitiesLeadsCommunications

Page 4: Sage CRM Developers Course

Getting Started

Do you have an email server to test with?VPOP– Paul Smith Computing Services– http://www.pscs.co.uk/downloads/vpop3.php

CMAIL– http://www.youngzsoft.net/

Page 5: Sage CRM Developers Course

Documentation and Resources

System Administration GuideE-mail ManagementE-mail Configuration and E-mail Status

Textpad Snippets– dpp.sagecrm.com

Page 6: Sage CRM Developers Course
Page 7: Sage CRM Developers Course
Page 8: Sage CRM Developers Course

Services

C:\program files\sage\CRM\services\eWareEmailManager.exe

Hkey_Local_Machine, System,Current Control Set, ServicesCRMEscalationServiceEmailManager

Page 9: Sage CRM Developers Course

Clean out Old Install Configurations

Open registryHKEY_LOCAL_MACHINE\SOFTWARE\eWare\ConfigGo through each install and blank– EMlogonid– EMPassword

Except for install to be used

Page 10: Sage CRM Developers Course

Advanced Email Manager

Support for e-mail MAPI and POPAllows separate inbound/outbound mail serversSecure SMTP supportedExternal databases may be read and written to via the custom scripting aspect.Each mailbox is accessed and controlled by its own thread within the application.

Page 11: Sage CRM Developers Course

Creating a New Script File

To create a new "Sales" email manager template.Save the template into the same folder as the other template files. C:\Program Files\Sage\CRM\Services\CustomPages\Scripts\sales.js

The template will automatically be seen and made available to CRM for use in the Administration -> E-mail and Documents -> E-mail Management Server Options when creating a new email address option.

Page 12: Sage CRM Developers Course

Create a New Function

To allow a new function to be called from within template then you will need to add the following Translation

Caption Family: jsfunctionsCaption Code: SalesEnquiry();US Translation: Sales Enquiry

Add other translations as required.

Page 13: Sage CRM Developers Course

Basic Structure of Template Files

See System Administration Guide

Mytemplate.jsCommentsInitialise VariablesGeneral Event Functions– BeforeMainAction– AfterMainAction

Main Functions (referenced in Config screen)– N.B. MainAction is a reserved word. Do not call any function ‘MainAction’ as this is internally

replaced with function called from configuration screen.

Utility Functions

Page 14: Sage CRM Developers Course

Debugging

Turn on Debugging in SystemIn Template will use:MsgHandler.Debug = true;

Page 15: Sage CRM Developers Course

Objects Available in Template

UserQueryeWareQuery object using– SELECT * FROM vUsers WHERE– user_emailaddress = FromAddress– OR– user_mobileemail = FromAddress

PersonQueryeWareQuery object using– SELECT * FROM vEmail, vPerson WHERE email_personid– = pers_personid AND emai_emailaddress = FromAddress

CompanyQueryeWareQuery object using– SELECT * FROM vEmail, vCompany WHERE– emai_companyid = comp_companyid AND– emai_emailaddress = FromAddress

eWareeWare object...logged on with admin user (as specified in configuration)MsgHandlerDebugging controleMailinterface to the email

Page 16: Sage CRM Developers Course

Monitoring of Account

Log informationC:\Program Files\Sage\CRM\Services\Logs\20100712 CRM MailManager.log

**********RulesScript is...********if (bCond){AssignedUser = 4;AssignedChannel = 1;SalesEnquiry();}**********End of RulesScript.****

Where additional rule sets are used the information passed to the script is changed**********RulesScript is...********if ((!CompanyQuery.EOF) && (CompanyQuery("comp_type")=="Customer")){AssignedUser = 4;AssignedChannel = 1;CreateRepeatSale();bCond=false;}

if (bCond){AssignedUser = 4;AssignedChannel = 1;SalesEnquiry();}**********End of RulesScript.****

Page 17: Sage CRM Developers Course

Errors in Log

Error detection is based on the status of the script after it runs. The E-mail Management application runs the script and captures the result of the script running.Log file will contain the script and the error information. The section where the script failed is highlighted. E-mails that cause the system to fail internally are saved in a rogue e-mail folder, which is located in ...\Program Files\Sage\CRM\Services\CustomPages\Scripts

Page 18: Sage CRM Developers Course

Email Object

PropertiesBody - String (read/write)IsHTML - Boolean (read/write)Subject - String; (read/write)Priority - Integer (read/write)Recipients - AddressList ObjectSenderName - String (read/write)SenderAddress - StringDeliveryTime - DateAttachments - AttachmentList ObjectBCC - AddressList ObjectCC - AddressList Object

MethodsSend()AddFile('physical path')Clear()Header("named header")

Page 19: Sage CRM Developers Course

Other Objects

AddressListProperties– Items(index)– Count - Integer(readonly)

Methods– AddAddress(Address, Name)

MailAddressProperties– Name - String (read/write)– Address - String (read/write)

AttachmentListProperties– Items(index)– Count - Integer(readonly)– LibraryPath - String

AttachmentProperties– Name - String (read/write)– Extension - String (read only)

Methods– Save(Name, Path)– SaveAs(Name, Path)

Page 20: Sage CRM Developers Course

Adding Debugging Messages

function BeforeMainAction(){MsgHandler.Log("BeforeMainAction function called");}

function AfterMainAction(){MsgHandler.Log("AfterMainAction function called");}

Page 21: Sage CRM Developers Course

Example Main Function

function SalesEnquiry(){

//add debug message to indicate that function called//if sender is known contact then log new opportunity//create communication//automatically acknowledge email

If sender is unknown then//create lead//create communication//automatically acknowledge email

}

function SalesEnquiry(){

MsgHandler.Log("SalesEnquiry function called");

//check if person existsif (!PersonQuery.EOF){createOppo();createComm("Opportunity");// sendEmail();}else{createLead();createComm("Lead");// sendEmail();}

}

Page 22: Sage CRM Developers Course

Example Create Opportunity

function createOppo(){

var myRecord = CRM.CreateRecord("opportunity"); myRecord.Oppo_PrimaryCompanyId= PersonQuery("pers_companyid");myRecord.Oppo_PrimaryPersonId= PersonQuery("pers_personid");myRecord.Oppo_AssignedUserId= AssignedUser;myRecord.Oppo_ChannelId= AssignedChannel;myRecord.Oppo_Description= eMail.Subject.substring(0, 39);myRecord.Oppo_Source= "Email";myRecord.Oppo_Note= "Please see the attached email";myRecord.Oppo_Status= "In Progress";myRecord.Oppo_Stage= "Lead";myRecord.Oppo_Opened = mydate.getVarDate();

myRecord.SetWorkflowInfo("Opportunity Workflow", "Lead")myRecord.SaveChanges();intOppoRecordID = myRecord.oppo_opportunityid;

}

Page 23: Sage CRM Developers Course

Example Create Lead

function createLead(){

var myRecord = CRM.CreateRecord("lead"); myRecord.lead_AssignedUserId= AssignedUser;myRecord.lead_ChannelId= AssignedChannel;myRecord.lead_Description= eMail.Subject.substring(0, 39);myRecord.lead_Source= "Email";myRecord.lead_Details= "Please see the attached email";myRecord.lead_Status= "In Progress";myRecord.lead_Stage= "NewLead";myRecord.lead_Opened = mydate.getVarDate();

myRecord.SetWorkflowInfo("Lead Workflow", "Assigned")myRecord.SaveChanges();intLeadRecordID = myRecord.lead_leadid;

}

Page 24: Sage CRM Developers Course

Example Send Email

function sendEmail(strsubject){

eMail.IsHTML = true;SenderName = eMail.SenderName;SenderAddress = eMail.SenderAddress;MailSubject = eMail.Subject;MailBody = eMail.Body;

eMail.Clear();eMail.Recipients.AddAddress(SenderAddress, SenderName);eMail.SenderName = MsgHandler.EmailAddress;eMail.SenderAddress = MsgHandler.EmailAddress;

if (strsubject == ""){eMail.Subject = CRM.GetTrans("GenCaptions", "AutoReply") + ": " + MailSubject}else{eMail.Subject = strsubject;}eMail.Body = CRM.GetTrans("GenCaptions", "Your mail has been logged") + "<BR>" +CRM.GetTrans("GenCaptions", "Thank you") + "<BR><BR>" + CRM.GetTrans("GenCaptions", "Panoply Support") + "<BR><BR>" + MailBody;eMail.Send();

}

Page 25: Sage CRM Developers Course

Q&A

Page 26: Sage CRM Developers Course

Looking ahead to the classes

DP01: Introduction to the Development Partner ProgramDP02: 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 RulesDP07: 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 ManagerDP12: Programming for the Advanced Email ManagerDP13: Using the Web Services APIDP14: 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)

Page 27: Sage CRM Developers Course