Microsoft Crm Programming Secrets ? Tips For Developers
|
This article is for advanced Microsoft CRM SDK C# developers. It describes the technique of direct SQL programming, when SDK doesn't have the functionality to do the job.
Introduction. Looks like Microsoft CRM becomes more and more popular, partly because of Microsoft muscles behind it. Now it is targeted to the whole spectrum of horizontal and vertical market clientele. It is tightly integrated with other Microsoft Business Solutions products such as Microsoft Great Plains, Solomon, Navision (the last two in progress).Here we describe the technique of creating closed activity-email using MS CRM SDK and direct SQL programming.
Imaging something like this. You need to handle incoming email before it is committed to MS Exchange database. You need to analyze if incoming email doesn't have GUID in its Subject (GUID will allow MS CRM Exchange Connector to move email to Microsoft CRM and attach it to the Contact, Account or Lead) - then you still need to lookup MS CRM in case if one of the accounts, contacts or leads has email address that matches with sender email address - then you need to create closed activity-email in MS CRM, attached to the object and placed into general queue.
How to create MS Exchange handler is outside of the scope, please see this article:http://www.albaspectrum.com/Customizations_Whitepapers/Dexterity_SQL_VBA_Crystal/ExchangeHandlerExample.htm
Now the code below is classical MS CRM SDK and it will create activity email:
public Guid CreateEmailActivity(Guid userId, int objectType, Guid objectId, string mailFrom, CRMUser crmUser, string subject, string body) {try {
log.Debug("Prepare for Mail Activity Creating");
// BizUser proxy object
Microsoft.Crm.Platform.Proxy.BizUser bizUser = new Microsoft.Crm.Platform.Proxy.BizUser();
ICredentials credentials = new NetworkCredential(sysUserId, sysPassword, sysDomain);
bizUser.Url = crmDir + "BizUser.srf";
bizUser.Credentials = credentials;
Microsoft.Crm.Platform.Proxy.CUserAuth userAuth = bizUser.WhoAmI();
// CRMEmail proxy object
Microsoft.Crm.Platform.Proxy.CRMEmail email = new Microsoft.Crm.Platform.Proxy.CRMEmail();
email.Credentials = credentials;
email.Url = crmDir + "CRMEmail.srf";
// Set up the XML string for the activity
string strActivityXml = "";
strActivityXml += "";
strActivityXml += "") + "]]>";
strActivityXml += "";
strActivityXml += userId.ToString("B") + "";
strActivityXml += "";
// Set up the XML string for the activity parties
string strPartiesXml = "";
strPartiesXml += "";
strPartiesXml += "" + crmUser.GetEmailAddress() + "";
strPartiesXml += "" + Microsoft.Crm.Platform.Types.ObjectType.otSystemUser.ToString() + "";
strPartiesXml += ""+ crmUser.GetId().ToString("B") + "";
strPartiesXml += "";
strPartiesXml += Microsoft.Crm.Platform.Types.ACTIVITY_PARTY_TYPE.ACTIVITY_PARTY_TO_RECIPIENT.ToString();
strPartiesXml += "";
strPartiesXml += "";
strPartiesXml += "";
strPartiesXml += "" + mailFrom + "";
if (objectType Microsoft.Crm.Platform.Types.ObjectType.otAccount) {
strPartiesXml += "" + Microsoft.Crm.Platform.Types.ObjectType.otAccount.ToString() + "";
}
else if (objectType Microsoft.Crm.Platform.Types.ObjectType.otContact) {
strPartiesXml += "" + Microsoft.Crm.Platform.Types.ObjectType.otContact.ToString() + "";
}
else if (objectType Microsoft.Crm.Platform.Types.ObjectType.otLead) {
strPartiesXml += "" + Microsoft.Crm.Platform.Types.ObjectType.otLead.ToString() + "";
}
strPartiesXml += ""+ objectId.ToString("B") + "";
strPartiesXml += "";
strPartiesXml += Microsoft.Crm.Platform.Types.ACTIVITY_PARTY_TYPE.ACTIVITY_PARTY_SENDER.ToString();
strPartiesXml += "";
strPartiesXml += "";
strPartiesXml += "";
log.Debug(strPartiesXml);
// Create the e-mail object
Guid emailId = new Guid(email.Create(userAuth, strActivityXml, strPartiesXml));
return emailId;}catch (System.Web.Services.Protocols.SoapException e) {log.Debug("ErrorMessage: " + e.Message + " " + e.Detail.OuterXml + " Source: " + e.Source);}catch (Exception e) {log.Debug(e.Message + "rn" + e.StackTrace);}return new Guid();}
Now I would like to share the trick with you - there is no method to make this activity closed in MS CRM SDK 1.2 (if somebody knows the one - I owe you small pocket aquarium - smile!). Obviously Microsoft doesn't support if you do direct SQL programming bypassing SDK. However I would say this is not direct objects creation - this is rather flags correction. So here is what we have - this procedure will do the job and make activity closed:
public void UpdateActivityCodes(Guid emailId) {try {
OleDbCommand command = conn.CreateCommand();
command.CommandText = "UPDATE ActivityBase SET DirectionCode = (?), StateCode = (?), PriorityCode = (?) WHERE ActivityId = (?)";
command.Prepare();
command.Parameters.Add(new OleDbParameter("DirectionCode", Microsoft.Crm.Platform.Types.EVENT_DIRECTION.ED_INCOMING));
command.Parameters.Add(new OleDbParameter("StateCode", Microsoft.Crm.Platform.Types.ACTIVITY_STATE.ACTS_CLOSED));
command.Parameters.Add(new OleDbParameter("PriorityCode", Microsoft.Crm.Platform.Types.PRIORITY_CODE.PC_MEDIUM));
command.Parameters.Add(new OleDbParameter("ActivityId", emailId));
log.Debug("Prepare to update activity code " + emailId.ToString("B") + " in ActivityBase");
command.ExecuteNonQuery();
}
catch(Exception e) {
log.Debug(e.Message + "rn" + e.StackTrace);
}}
Happy customizing! if you want us to do the job - give us a call 1-866-528-0577! help@albaspectrum.com
Andrew Karasev is Chief Technology Officer in Alba Spectrum Technologies ? USA nationwide Microsoft CRM, Microsoft Great Plains customization company, based in Chicago, Boston, San Francisco, San Diego, Los Angeles, Houston, Atlanta, New York, and Miami and having locations in multiple states and internationally (www.albaspectrum.com), he is Dexterity, SQL, VB/C#.Net, Crystal Reports and Microsoft CRM SDK developer.
|
|
|
Microsoft Crm For Corporate Business ? Working Offline
If your company has regional and worldwide operations, you might already realized that it is very hard to get decent internet connection in your remote locations. In this small article we will try to give you highlights on how to implement Microsoft Business Solutions CRM for worldwide operations with restricted internet connection.? Outlook Client. This was very bright idea from Microsoft side to have outlook client as a presentation for Microsoft CRM data. Outlook has such nice features as synchronization and then working offline. If you have outlook client for CRM ? you can download your customers, leads, contacts, and event properly programmed custom features, then work with them and finally synchronize them back to MS CRM database? MS CRM Integration. As the task itself it is not difficult or challenging ...(related: Software)
The Xp Firewall Isnt Enough
You might think you don't need a firewall because windows XP has onebuilt in,but read on for a plain-english explanation why this isn't enough.Before broadband and cable connections were common most people didn't need apersonal firewall because they weren't connected to the Internet for extendedperiods of time.Every computer that connects to the internet has an IP address. This is likea sort of phone number, and is issued either to an individual computer or toa "gateway" that connects a private network to the 'net.Domestic dial-up internet connections normally use a system called DynamicIP Addressing where people are issued with a sort of "new identity" everytime they connect, so it's difficu...(related: Software)
C++ Tutorials: 3, Program Flow (if, Else, While, For)
Program Flow is what you think it is. How the program will flow. As you know the compiler will just go down the code. Program flow is what you use to make it run a certain thing a few times, do something based on a variable, etc... There are some basic comands to program flow. The first two are loops: While and For. When you want something to loop for an amount of times based on a variable, use while. If you...(related: Software)
Microsoft Great Plains Partner Selection: Overview
Microsoft Great Plains, Navision, Solomon and Axapta are Microsoft Business Solutions ERP applications, serving to the whole spectrum of vertical and horizontal markets. Assuming that you already have one of these systems installed and implemented we would like to give you - IT director, Database Administrator, Programmer, Software Developer, Controller your options in supporting/upgrading Microsoft Great Plains for your companyIt is always good idea to install everything on your own - however Great Plains requires combination of computer networking, some programming, good accounting/distribution/logistics/reporting background - so it is not a surprise that Microsoft Business Solutions requires their customers to have specially assigner Microsoft Great Plains Partner/VAR/Reseller to serve the account.First Scenari...(related: Software)
Information Products: A Business Owners Best Friend
We live in a post-industrial age where information is the coin of the realm. Knowledge is the most valuable asset that a business owns. For most businesses, that knowledge exists primarily in the heads of the people who work there. For entrepreneurs and sole practitioners, what's in their head usually is the business. That's both limiting and dangerous.Let's take the example of a successful management consultant. Drawing on her knowledge and experience, she's able to hire herself out at a substantial hourly rate. The trouble is, every time...(related: Software)
Navision Customization: C/side, C/odbc, C/front, Xbrl ? Development Options
Microsoft bought Navision, Denmark based software development company, along with Great Plains Software. Now Microsoft Business Solutions offers following ERP applications: Navision (former Navision Attain), Microsoft Great Plains (former Great Plains Dynamics/eEnterprise), Solomon, Axapta. Formerly Navision had strong positions in Europe. Now it is promoted in USA and Europe. Navision has pretty advanced manufacturing module.We would like to give you: programmer, software developer, database administrator the ori...(related: Software)
Internet Faxing Service Review
The Internet is reshaping every form of communications medium, and faxing is no exception. The latest twist: Internet faxing services that let you send messages to any fax machine from any Web b...(related: Software)
Corporate Erp: Microsoft Great Plains For The Plant In Brazil ? Overview For Cio
Microsoft Business Solutions Great Plains as new ERP for multinational corporation manufacturing facility in Brazil.If your company plans to outsource manufacturing in Brazil by purchasing existing facility there, the first step would be to implant new management team and revise business processes and procedures. The way there comes through the new ERP/accounting system implementation from scratch. We'll show you the way to implement new system on the base of Microsoft Great Plains. You may have two reasons to place Great Plains, first ? you company has Great Plains implemented in the headquarters and this is worldwide policy, second ? if you have high end ERP at the headquarte...(related: Software)
Lotus Domino/notes - Microsoft Great Plains Tandem As Erp With Documents Workflow - Overview For It
Lotus Domino/Notes ? Microsoft Great Plains tandem as ERP with Documents Workflow ? overview for IT SpecialistMicrosoft Business Solutions has the whole spectrum of business applications, the good combination seems to be Microsoft Great Plains and Microsoft CRM. However we need to admit that Microsoft is relatively new in the CRM market and also for large corporation it could not be a good idea "to put all the eggs into one basket". If you ...(related: Software)
site-map - Copyright © 2008 | Contact Webmaster | All Rights Reserved. | Software