Showing posts with label CRM Online. Show all posts
Showing posts with label CRM Online. Show all posts

Wednesday, January 27, 2016

CRM Outlook Client: Emails Tracked to Inactive Records

The way the CRM Outlook client tracks emails and links them to CRM records is based on email address.  It will take the customer's address from the email and search the entire CRM system for any records with an exact match.  This search covers any entity with an email address field, including custom entities, regardless of record status or anything else, really.  This can sometimes create a couple issues:

Problem #1: Emails are tracked to entity types that you don't necessarily want them tracked to. 
Unfortunately, CRM does not let you dictate which record types the Outlook Client tracks emails to.  As long as there's an email address field on the entity, the Outlook Client will attempt to link to it.

The fix: There is no way to turn off individual entity types from Outlook tracking.  This is something to keep in my when designing your entities.  If you have an entity that must have an email address stored on it, consider creating the field as a simple, single line of text.  Unless it's configured as an email-type field, the Outlook client will ignore it.

It's important to note, too, that once you create an email field on an entity, Outlook will search that entity for matches, and CRM doesn't let you undo or disable that.  

Problem #2: Emails get tracked to inactive records.  
One thing we've noticed after several years of using the CRM Outlook client is that it does not discriminate between active or inactive records.  CRM will try to link emails to matching email addresses on records regardless of record status.  As a result, you may notice inactive records being linked to your emails.

The fix: As we already know, CRM take a blanket approach to linking emails.  The key in linking track an email against a record is the email address.  So, if you want inactive records to be ignored by the Outlook client you can create a workflow or plugin that deletes or changes the email address upon deactivation.  For one of my clients we just add "-inactive" to the end of the email address.  Adding this text will cause CRM to not recognize the email address and skip over it.

Thursday, December 24, 2015

How to Find Your CRM Online IP Address

I was recently asked to build a CRM extension to submit Opportunity records to an external API. We decided to build this as an asynchronous custom workflow activity so it would trigger upon Create, but also could be called manually. Behind the scenes I use C# to make an HTTPWebRequest, using values from the Opportunity record.  So, the user would create an Opportunity record, then run the workflow which gathers data from the Opportunity and sends it the the external API for processing.

Making a web call from CRM is generally straightforward, but this case was a little different - the external API required us to register our IP address with them for authentication, and then use that IP address in all subsequent calls.  At first I though finding CRM's IP address would be easy - I'd just use one of the many IP lookup sites out there and plug in the web url (e.g., "https://myorg.crm.dynamics.com"), and we'd be done.  But it's not that straightforward (it never is).  

CRM uses separate servers for asynchronous processes (asynchronous workflows included).  So while your front end application server ("https://myorg.crm.dynamics.com") has one IP address, the custom workflow activity will come from a different one.  How do you find the IP address of your asynchronous server?  After trying many methods, I used the code below to do this.  This code makes a WebRequest call to a site called "ipify", which tells you your IP address from programmatic calls.  It then reads the response (the IP Address) into an Output argument which the CRM workflow puts into a field on the Opportunity record.  

There may be easier ways to find your IP address, but I did it this way because of the limited access we have to server level information in the cloud.  I tried several DNS property calls and got security errors.  So the last way I could think was to record on the receiving end of the call (thanks https://www.ipify.org/ !!!).  

Disclaimer: CRM Online uses several IP ranges which you can find here.  While this code will tell your current IP address at the time of the call, your IP address can and will change unexpectedly.  That said, this will tell you want range you're in, and I hope this code is helpful to someone out there because I spent many hours before finally figuring this out.  

string tmaurl = "https://api.ipify.org";
WebRequest request = WebRequest.Create(tmaurl);                                    
WebResponse response = request.GetResponse();

WebHeaderCollection header = response.Headers;
using (var reader = new System.IO.StreamReader(response.GetResponseStream()))
{
    string responseText = reader.ReadToEnd();
    this.ServerMessage.Set(executionContext, responseText);
}

[Output("Server Message Output")]
public OutArgument<string> ServerMessage { get; set; }