Software Information |
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.
MORE RESOURCES: Unable to open RSS Feed $XMLfilename with error HTTP ERROR: 404, exiting |
RELATED ARTICLES
Microsoft Great Plains Dynamics on Pervasive SQL.2000 Data Repair - Overview For DBAs Some introduction into Great Plains Software products, now Microsoft Business Solutions. Microsoft Great Plains becomes more and more popular, partly because of Microsoft muscles behind it. Adware and Spyware Blockers The most important things you can do for your computer right now is to install adware and spyware blockers. Everyone is aware of computer viruses and run an anti-virus program to guard your computer against them. Microsoft Navision and Crystal Reports - An Overview Microsoft Business Solutions - Navision is an integrated solution for small and midsize companies looking to expand their business operations without much interruption to its existing processes. Microsoft Navision enables businesses to alter as much or as little of its existing system, integrate add-ons and vertical segments of its development. Change Your Word Docs in Record Time! Anyone who has ever used Microsoft Word knows that it is a powerful word processing package. It's loaded with dozens of features designed to make creating documents a breeze. Microsoft Great Plains Implementation for Large Corporation - Overview for VP IT Microsoft Business Solutions Great Plains was historically designed to serve mid-market first and then with addition and acquisition of new modules - Great Plains Dynamics architects planned to enter into corporate market. When Microsoft SQL Server took its place as relatively reliable and stable database platform, Great Plains gained scalability. Begun, The Browser Wars Have As Mozilla Firefox nears 10% market share, with well over 25 million downloads direct from the makers website, and goodness knows how many through other sources, Microsoft announces that it will be releasing IE 7 ahead of schedule. Originally scheduled for release with Microsoft's new Longhorn operating system in 2006, it seems that Microsoft are reacting to the run away success that Firefox has had over the last few months. Pros and Cons of Using FREE Software in Your Business Itâ??s easy to understand why you might be drawn to the allure of free software. After all, it is free and free is always a good price to pay. SSH (SCP) Send Files from Windows to Your Linux Box Not all of us have the luxury of working both at home and at work on a UNIX based system. However that doesn't mean you can't transfer files safely and securely between the two systems. Spyware Protection: A Must for Any Home Computer Now that spyware is the single most dangerous threat to home computers connected to the internet today, getting your hands on some sort of spyware and adware protection is critical. Spyware has outpaced computer viruses in its prevalence, and in the kind of damage it can do to your system. How to Choose the BEST Charting Software I suggest that you do not spend a lot of money on charting software as most perform very similar functions. Often the price is inflated to capitalize on the mentality that expensive is better. Protect Your Computer...and Your Business! We all take the computer for granted. I mean, all we have to do is switch it on and it's ready to go. How to Tell You Have Spyware, Ad-ware or Viruses Usually, the easiest way to tell you have spyware is because your PC is running at a reduced speed. The other way to check is to hit CTRL+ALT+DELETE and hit task manager (if you have windows service pack 2. Five Tips For A Great Software Demo Whether you need to close a sale, gather end-user feedback, show progress to your customer, or simply explain how your product works, sooner or later, you will need to demo your software product.Over the years, I've had the opportunity to perform hundreds of demos to audiences of various sizes. Microsoft CRM Integration With Microsoft Office Documents - Overview For System Integrator Microsoft CRM is CRM application, maintained and supported by Microsoft Business Solutions. Microsoft CRM utilizes majority of the Microsoft technologies: Windows Active Directory, SQL Server, MS Exchange, BizTalk (integration with MS Great Plains, and soon with Navision), Message Queuing, . Microsoft Great Plains Implementation: Verticals - Wholesale Order Entry center - overview Microsoft Business Solutions Great Plains has substantial market share and strong support by Microsoft on the US market. Currently we see the trend in the vertical markets when companies with custom-built accounting application, usually written on legacy platform are switching to standard and proven ERP solution and customize or tailor it to fit their vertical market requirements. Anti-Spyware Protection - Holes in the Shining Armor Looking at all the ads which promise to get rid of all spy programs, one may wonder why there is still plenty of them everywhere and the situation is by no means getting better. So let me spoil the advertisers' mood and show some of the "holes" in the majority of software products we expect to protect our data. Perfectly New Database Query Tool - Foxy SQL Pro Released Are you a database professional? Do you work with a lot of databases? Do you use an SQL code? Do you want to connect to a new database to physically create its structure in no time and with ease? Are you tired of having to handle several client applications?If your answer is "yes" to any of these questions, I recommend you to go on reading this article.Let's imagine you work with let's say three databases. Microsoft Business Solutions Partner - How to Launch New IT Consulting Practice In the new era of internet marketing the problem of severe competition comes into the first position. If you look back into 1990-th you will find high tech companies using traditional sales techniques: purchasing local and regional businesses contact lists, making cold calls and then trying hard sales closing techniques, such as "selling to the top" - IBM style, selling to VITO (very important top officer), etc. Navision Attain C/ODBC Crystal Report - Customization Example Microsoft Business Solutions Navision is main ERP application for European, Brazilian markets plus it serves vertical segments of the USA market, such as light manufacturing, POS, CRM. As our experience indicates - Navision implementation requires more customization and tuning in comparison to another mid-market ERP solution from MBS: Microsoft Great Plains. Microsoft Great Plains Integration with Microsoft Access - Overview for Developer Microsoft Business Solutions stakes on Microsoft Great Plains as main Accounting/ERP application for US market. At the same time it seems to be staking on Navision in Europe and has Axapta as high end large corporation market competitor to Oracle, PeopleSoft, SAP, IBM. |
home | site map | contact us |