Software informational articles

Microsoft crm training secrets ? tips for developers - software

 

This commentary is for far ahead Microsoft CRM SDK C# developers. It describes the performance of aim SQL programming, when SDK doesn't have the functionality to do the job.

Introduction. Looks like Microsoft CRM becomes more and more popular, partially since of Microsoft muscles at the back of it. Now it is besieged to the whole spectrum of horizontal and vertical promote clientele. It is tightly integrated with other Microsoft Commerce Solutions foodstuffs such as Microsoft Great Plains, Solomon, Navision (the last two in progress). Here we express the modus operandi of creating clogged activity-email using MS CRM SDK and as the crow flies SQL programming.

Imaging a touch like this. You need to carry incoming email beforehand it is committed to MS Altercation database. You need to evaluate if incoming email doesn't have GUID in its Area of interest (GUID will allow MS CRM Barter Connector to move email to Microsoft CRM and ascribe it to the Contact, Checking account or Lead) - then you still need to lookup MS CRM in case if one of the accounts, contacts or leads has email deal with that matches with sender email concentrate on - then you need to construct blocked activity-email in MS CRM, fond of to the aim and sited into broad-spectrum queue.

How to build MS Altercation handler is exterior of the scope, entertain 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 build commotion email:

public Guid CreateEmailActivity(Guid userId, int objectType, Guid objectId, chain mailFrom, CRMUser crmUser, line subject, line body) { try {

log. Debug("Prepare for Mail Action Creating");

// BizUser proxy object

Microsoft. Crm. Platform. Proxy. BizUser bizUser = new Microsoft. Crm. Platform. Proxy. BizUser();

ICredentials authorization = 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 cord for the activity

string strActivityXml = "";

strActivityXml += "";

strActivityXml += "") + "]]>";

strActivityXml += "";

strActivityXml += userId. ToString("B") + "";

strActivityXml += "";

// Set up the XML chain for the commotion 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);

// Coin 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 approach to make this bustle blocked in MS CRM SDK 1. 2 (if a name knows the one - I owe you small bag aquarium - smile!). Apparently Microsoft doesn't aid if you do aim SQL encoding bypassing SDK. But I would say this is not as the crow flies stuff conception - this is considerably flags correction. So here is what we have - this modus operandi will do the job and make bustle closed:

public void UpdateActivityCodes(Guid emailId) { try {

OleDbCommand authority = 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 bring up to date commotion 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 Knowledge Executive in Alba Spectrum Technologies - USA generally 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 numerous states and globally (www. albaspectrum. com), he is Dexterity, SQL, VB/C#. Net, Gem Hearsay and Microsoft CRM SDK developer.


MORE RESOURCES:
Developed by:
home | site map
goldenarticles.net © 2018