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 ( http://www.albaspectrum.com
), he is Dexterity, SQL, VB/C#.Net, Crystal Reports and Microsoft CRM SDK developer.

Article Source: http://EzineArticles.com/?expert=Andrew_Karasev

Admiral Yamamoto, the leader of the Japanese Fleet that bombed Pearl Harbor, knew the United States of America had an industry base that was unmatched in the world. He had spent time in the United States and seen that even though the United States was caught in the Great Depression it still had great industrial capacity. This is why he actually advised that Japan not go to war with the United States.

The United States became the most powerful nation on earth by being an industrial giant. This was demonstrated during World War II. But, the industrial power that Admiral Yamamoto feared no longer produces most of the world’s industrial goods. The United States’ economy is changing from an industrial economy to one driven by the service industry. We do not build the goods we use, but we service them.

Computers and the software that powers them, truly highlight this service economy. Computers are built in many different countries, usually not the United States, but IT personnel within corporations service the machines, or outside maintenance companies are brought in to fix glitches. The service business in computer technology continues to grow. Now a company of any size can rent server space, use a consulting company to host software, and receive advice on how to better use current technology.

Microsoft is the leading and most popular name in computer software. Yet, small businesses do not have to buy Microsoft software. Small Business CRM MS is available from other companies who host Microsoft products. This idea of offering software service to small businesses gives them the opportunity to have Customer Resource Management (CRM) that compares to large corporations throughout the world, and being able to better understand the customer is the most important thing in business.

Being able to apply the important tools of business will help the service economy of the United States grow into the power that the industrial economy once was. The service corporations in the computer field will help other business apply necessary CRM software. This MS CRM application process will help business of all sizes better understand where they need to go to better compete in the global economy, and ultimately, helping the United States’ economy.

Microsoft is a strong corporation. Their tools are useful to small businesses and major corporations. The Hosted Dynamics Microsoft CRM 3.0 will be helpful to any business. This is how a host company is useful. Like industrial giants working together to make the United States stronger during World War II, companies can work with companies whose sole purpose is to serve other’s software.

Phase 2 International is one company that is hosting software for other businesses and corporations. This Honolulu based company is helping the United States’ service economy, and helping many businesses throughout the world. If you are looking to learn more about Small Business CRM MS
, any MS CRM application
, or Hosted Dynamics Microsoft CRM 3.0 then head directly to Phase 2 International’s website to learn more.

Article Source: http://EzineArticles.com/?expert=Alice_Lane

SAP B1 ERP has integrated CRM functionality and you can purchase named user licenses for CRM only at half of the normal all-in-one user license price. Client Relation Management business logic typically fits to your sales people and considering typical business office, you may have as many as half of all office employee working in Sales department, CRM licenses might help your budget in Software purchasing and implementing. Let’s review the functionality:

1. Opportunity. This is the key CRM object. Opportunity might be assigned to either Customer or Lead Business Partner. Toward opportunity you can do activities, such as phone calls, meetings, task, note or other. You also can associate opportunity with Partner channel – if you sell SAP products you can associate with SAP BO product line (SAP Business One you can make a partner for opportunities). Also you can associate opportunity with competitor, for example Microsoft Dynamics. Plus for the opportunity you can select existing or create new quotation or sales order, in this case you may decide to update opportunity budget from Quote or Order

2. Opportunity phases and stages. By default new opportunity is created in open phase. Then as you go with your sales cycle you can move it to won or lost phase. In CRM setup you define opportunity stages with estimated closing percentages at each stage. As well you enumerate stages. You can also move back to previous stages. Good example is negotiation and following quotation stage. You can move back from quotation to further additional negotiation

3. Related Documents. These are quotes and sales orders. If you have multiple re-negotiation steps you may associate multiple sales documents to the same opportunity and every time you can update budgets and plus closing estimated percentages

4. Opportunity reporting. Here, as you normally expecting from SAP BO, reporting is really sophisticated and at the same time pretty intuitive. Besides standard reporting we encourage you to practice or establish good habit to practice in SAP B1 unique drag-and-relate technology, which is very cool feature, resembling data mining and warehousing

Andrew Karasev, Alba Spectrum Group, http://www.albaspectrum.com
, help@albaspectrum.com
1-866-528-0577, we serve you USA nationwide, first by providing web presentation and if required sending our Sales Engineer ons ite at no cost to you. We have local reps in Chicago, South Carolina, Atlanta. However we send our consultants to you again at no travel and lodging cost for implementation on site. Please visit our media portal http://www.pegasplanet.com

Article Source: http://EzineArticles.com/?expert=Andrew_Karasev

  • Share/Bookmark