Sonoma Partners Microsoft CRM and Salesforce Blog

CRM: When Homemade Doesn't Cut It

Today's blog post was written by Kayla Silverstein, Marketing Specialist at Sonoma Partners.

There are a lot of scenarios in which homemade is best – be it chocolate chip cookies, cozy knitted socks, or an old-fashioned rocking chair. When it comes to building a CRM system to meet the complex needs of your business, a homegrown CRM system will not provide you with the business tool you crave.

SP_Homemade_CRM_blog

Customer Relationship Management tools are critical to building relationships and growing businesses. Market-leading platforms like Dynamics 365 (formerly Dynamics CRM Online) and Salesforce are market-leading for a reason – they are used by organizations of every shape and size to improve sales performance, proposal generation, marketing automation, and so much more.

Here are 3 things you’re missing out on when you choose to invest in a homegrown CRM system:

1. No updates for you.

When you invest in Salesforce or Dynamics 365, you have access to the tools, functionality, and integrations your team needs to productively operate. From forecasting to integrations, incorporating these features in your homegrown platform can come at a huge cost. The market-leading CRM platforms provide access to today’s vital features and tomorrow’s future innovations. Technology is moving faster than ever, and investing in a name brand platform ensures you can keep up.  

With a homegrown CRM system, the only updates your system is going to receive are the ones you create. By comparison, both Salesforce and Dynamics 365 release updates 2-3 times a year. With these updates, you’re getting access to new features, tried and tested for users just like you and your team. In our experience, we’ve seen about 200-500 new features per release. That’s anywhere from 400-1,500 features a year! How many features do you think, even in your slower seasons, your development team could put together? Probably not 1,500.

2. Forget about custom UX.

Investing in a thoughtful, engaging user experience design provides your team with a tool they  want to use. When you configure Dynamics 365 or Salesforce in a way that satisfies your team’s daily operations, you can present your employees with a trusted platform that uniquely meets their needs. Investing in custom UX is one way to drastically increase both user adoption and the quality of data in your CRM system.

With the steep costs of developing custom UX within a homegrown platform, you could be left with a system that your users will not adopt. With inconsistent use, the system grows stale and underutilized. When you work with Microsoft Dynamics CRM or Salesforce, you can build completely custom mobile applications, enhance simple controls, or deploy fully-branded portals. The sky is the limit!

3. Lack of support.

CRM implementations are naturally works-in-progress. Your different teams are utilizing the system for a variety of means, and odds are, you won’t be able to update every department at the same time. This is one of the reasons Salesforce and Microsoft dedicate time and money to an array of support networks for their users. As a customer, you can access crowdsourced information from blogs and partner channels, to self-help portals to get you the answers you need and fast. Support for your homegrown solution is at the mercy of whoever is around to assist. To set yourself up for success in the long term, invest money where you can get continued assistance and resources to support the road ahead.

If you have questions about how your organization can start investing in a Salesforce or Dynamics 365 solution, feel free to drop us a line.

Feel you’ve gone past the point of no return with your homegrown solution? Don’t panic. We offer a variety of resources to help get you back on course. Start with our eBook on The Trail to CRM Triage, helping you begin the 5-step trail to solve stalled or static CRM solutions.

Topics: CRM Best Practices

Power BI Online Integration with Dynamics CRM On-Premise

Today's blog post was written by Hayden Thomas, Associate Developer at Sonoma Partners.

Integrating Power BI online with Dynamics CRM On-Premise is not currently supported natively. Recently we had a need to integrate a Power BI Report with a Dynamics CRM On-Premise environment, so we needed to create a custom solution to enable embedding reports and dashboards from Power BI into CRM.

Power BI natively allows reports to be ‘Published to Web.’  Doing this would allow us to simply IFrame the report on a Dynamics form or dashboard, but this makes it accessible to anyone who may have the link which is not very secure. This is unsuitable as the reports we’re looking to embed may have sensitive data which we want to make absolutely sure no one has outside access to.

In our case, we are connecting to Power BI through Azure. Azure uses OAuth 2.0 and Active Directory services for authentication. We need to be able to store:

  1. A Client ID that represents a connection to Power BI through Azure.
  2. A Tenant ID for our Azure Active Directory.
  3. An access token that will allow us to request a report from Power BI.
  4. A refresh token that will allow us to programmatically keep our authentication alive, so that we don’t need to continuously keep putting in our username and password.
  5. The lifespan of the authentication and the date-time we obtained it, so we can check if our current authentication is still good.

The Client and Tenant ID are the same for all of the users in our org, so we simply created a configuration record to hold these values.

The other fields will either be created for every user and we need to ask the user to enter their authentication to populate these fields, or we need to create a service account that can be authenticated in the background without the user needing any information on how the reports are being displayed.

Our solution used the second option. Our reports are shared amongst a group in Power BI. In order to have everyone log in and have their own tokens, it would require them to all be added to that group (and in turn, require everyone to have a Power BI Pro license). This also allowed us to just add the authentication fields to the configuration record, along with the service account’s username and password.

Powerbi brendan 1

Our next step is to make sure we actually have an app registered to our Azure AD that we can authenticate this user against. If we log in to dev.powerbi.com/apps, we can register one directly to ensure that it’s set up correctly. In order to make sure we don’t need to handle anything with redirect URLs, since we expect to move this around to different orgs without much issue, we use Native app from the App Type drop down, and for our redirect URL we use this link. For our case, where we only want to be able to read dashboards/reports, we only give it the read all dashboards and read all reports access levels. Once done, we can click Register App to obtain the Client ID we will use for our configuration record.

We have our app created, but haven’t yet given permission from our service account to the app to be able to log the user in programmatically. In order to give permission, we wrote a LINQPad script that does nothing but connect to the Client ID of our app, and allow the user to log in to give access.

Powerbi brendan 2

Running the script will pop up a dialog to allow a user to log into the App created with the specified client ID.

Powerbi brendan 3

In order to connect and display the report, we look to the Power BI documentation on how to show a report in an IFrame. https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-integrate-report-load-report-iframe/. We see that we need an embed URL and an access token. Since we need to send information to the IFrame after it’s already set, and because we want to be able to use different reports in different areas, we create an HTML web resource that’s got an Iframe in it, and set the frame contents accordingly using JavaScript.

Powerbi brendan 4

Excess code for styling and other libraries used in JavaScript removed for brevity.

The JavaScript in this page does a number of things. When the resource initially loads it parses the report ID and the group ID, in which the report is stored, from the query string. This lets us use the same web resource on the same page to load multiple reports. In the web resource properties on dynamics, we can set this report and group ID field accordingly in the custom parameters.

Powerbi brendan 5

It then triggers a custom action that takes in both of those parameters. The custom action triggers some plugin code that loads the configuration record, ensures the authentication is up to date, and then queries Power BI for the embed URL for that report.

For ensuring our authentication is up to date, we see if we have an access token or if our token has expired (based on the authentication lifespan and authentication obtained date time fields we have on our configuration). If we don’t have a refresh token, we need to use the password grant_type along with the service account username and password. (If we can refresh, we do something similar using grant_type refresh and the refresh token that we have stored in our configuration record. More details on Azure OAuth operations can be found here: https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols-oauth-code). In this example, we deserialize into an AccessToken model class that’s described by the documentation above.

Powerbi brendan 6

With our access token, we can query Power BI for the reports which are shared with the Group ID we sent added as a parameter by doing an HTTP GET request against https://api.powerbi.com/v1.0/myorg/groups/GROUP_ID/reports with an Authorization: Bearer ACCESS_TOKEN header.

Powerbi brendan 7

This will give us a response that’s a JSON string which will be an array of all of the reports for the group. Each entry in the array will contain the report ID and the embed URL. There are additional fields, such as the display name for the report, but they’re unimportant for what we’re doing. We simply need to find the entry that has the report ID that we passed in, and return the embed URL and access token back to the web resource. Powerbi brendan 8

Once we have those fields in the client side, we can simply set the source of our Iframe to the embed URL we received, and post the access token to it.

Now we can see our Power BI report as an iFrame.  In this case we embedded as a Dashboard in Dynamics CRM.

Image5

Topics: Microsoft Dynamics 365 Microsoft Dynamics CRM

Async is Smooth, Smooth is Fast

Today's blog post was written by William "Dibbs" Dibbern, Principal Developer at Sonoma Partners.

Having worked with Dynamics 365 for Sales (CRM) for nearly seven years now, we've seen a lot of things which cannot be unseen when it comes to client-side code. Whenever we get called in to evaluate the current state of an implementation, a good gauge by which to judge the state of the union is a glance at the JavaScript. Since JavaScript as a language is so forgiving, you can end up with a lot of code that "just works" but suffers in the areas of durability, maintainability, and performance.

What's the number one offense we see? Synchronous service calls.

When code degrades the end user experience, it shoots straight to the top of our "fix it now" list.

What's so bad about synchronous service calls?

Synchronous service calls have been prooven to be detrimental to the user experience. The browser literally stops everything to wait for the result of that call. When the browser is locked up waiting for the result of a synchronous service call, the user can't click anywhere else, enter any other information, cancel the operation, nor see any updates. Accordingly, users can't be given a glimpse into any synchronous operation's progress. In certain browsers, like Google Chrome, these types of synchronous requests are even becoming deprecated so you won't be able to do them much longer.

How do we fix this on forms?

Synchronous requests from the form are fairly straight forward to transition to asynchronous calls. Either continue processing the result in a callback function, or even better, you can implement promises for a cleaner way of dealing with multiple service calls. This does require a bit of thinking, but after a few refactories it quickly becomes second nature. Hastily written code almost always has a side effect, a few minutes saved coding could cost users hours of productivity in the long run.

Below is a contrived example where we retrieve the full name of the primary contact for the current record's parent account. Phew that's a mouthful. Long story short: let's retrieve a value from a related record. This example is designed as such purely to demonstrate the difference when multiple service calls are required, so yes, you can actually retrieve the required information in one service call. Also note that I've abstracted away all of the underlying XMLHttpRequest code, expecting that you are using a library to wrap that as well (though hopefully not jQuery, but that's another subject for another post).

  /* Bad */
  function onParentAccountChanged(parentAccountId) {
  var parentAccount,
  primaryContact;
   
  if (!parentAccountId) {
  return;
  }
   
  parentAccount = WebAPI.get('/accounts?$filter=accountid eq ' + parentAccountId);
   
  if (!parentAccount || !parentAccount._primarycontactid_value) {
  return;
  }
   
  primaryContact = WebAPI.get('/contacts?$filter=contactid eq ' + parentAccount._primarycontactid_value);
   
  if (primaryContact && primaryContact.fullname) {
  Xrm.Utility.alertDialog(primaryContact.fullname);
  }
  }
   
  /* Good (using callbacks) */
  function onParentAccountChanged(parentAccountId) {
  if (!parentAccountId) {
  return;
  }
   
  WebAPI.get('/accounts?$filter=accountid eq ' + parentAccountId,
  function onSuccess(parentAccount) {
  WebAPI.get('/contacts?$filter=contactid eq ' + parentAccount._primarycontactid_value,
  function onSuccess(primaryContact) {
  if (primaryContact && primaryContact.fullname) {
  Xrm.Utility.alertDialog(primaryContact.fullname);
  }
  },
  function onError(e) { /* handle error */ });
  },
  function onError(e) { /* handle error */ });
  }
   
  /* Good (using promises) */
  function onParentAccountChanged(parentAccountId) {
  if (!parentAccountId) {
  return;
  }
   
  WebAPI.get('/accounts?$filter=accountid eq ' + parentAccountId)
  .then(function onSuccess(parentAccount) {
  return WebAPI.get('/contacts?$filter=contactid eq ' + parentAccount._primarycontactid_value);
  })
  .then(function onSuccess(primaryContact) {
  if (primaryContact && primaryContact.fullname) {
  Xrm.Utility.alertDialog(primaryContact.fullname);
  }
  })
  .catch(function onError(e) { /* handle error */ });
  }

 

Did you notice how with the last good example, using promises, that the flow is actually very similar to how you would do things synchronously? That's one of many reasons why we love promises.

Did you also notice how the code in the callbacks example, with all the indentation, starts to look like a pyramid? That's one of the many reasons why we don't like callback as much as promises. You could flatten that out by pulling out the callback functions and defining them alongside onParentAccountChanged but let's be honest here, that doesn't usually happen until it's too late.

What about the command bar (ribbon)?

Ok. Let's address the tricky bit: custom enable rules. You might think you need your code to immediately return the result of your service call so that Dynamics knows to show the button as enabled or disabled, but this is not the case. You can return a smart default (usually default to disabled), do your service calls to determine what the actual state of it should be, and then refresh the ribbon (by invoking Xrm.Page.ui.refreshRibbon()) such that it presents that newly determined state. A bit steppy, with a potential for a flash of disabled -> enabled or vice versa, but overall a better experience than having the form lockup.

Looking for an example? Have a look below. The following example checks if the parent account's primary contact field is set:

  /* Bad */
  function isPrimaryContactSet(accountId) {
  var account;
   
  if (!accountId) {
  throw new Error('`accountId` is a required parameter for `isPrimaryContactSet`');
  }
   
  account = WebAPI.get('/accounts?$filter=accountid eq ' + accountId);
   
  if (account._primarycontactid_value) {
  return true;
  }
   
  return false;
  }
   
  /* Good */
  var isPrimaryContactCheckComplete = false,
  isPrimaryContactSetResult;
   
  function isPrimaryContactSet(accountId) {
  if (!accountId) {
  throw new Error('`accountId` is a required parameter for `isPrimaryContactSet`');
  }
   
  if (isPrimaryContactCheckComplete) {
  return isPrimaryContactSetResult;
  }
   
  WebAPI.get('/accounts?$filter=accountid eq ' + accountId)
  .then(function onSuccess(parentAccount) {
  if (parentAccount._primarycontactid_value) {
  isPrimaryContactSetResult = true;
  }
  else {
  isPrimaryContactSetResult = false;
  }
   
  Xrm.Page.ui.refreshRibbon();
  })
  .catch(function onError(e) { /* handle error */ });
   
  return false;
  }

 

Let's take note of a few key differences found in the "good" example:

  1. The service call is only ever run once as the result is cached.
  2. We default the button to disabled as the first time it hasn't run so we end up returning false.
  3. The variables storing the state of the call are stored outside the function being invoked. I would expect those variables not to be global variables however, they should instead be local to a parent scope that is not the global scope. This will help avoid conflicts.

A Special Note on Progress Indicators

I'm guessing by now you may have had the thought that since we're not locking up the browser any more, the user is now free to double click buttons and duplicate actions. I believe there are certain time frames in which that is fine. As long as a user sees a relatively instanteous response of any positive form, they are not very likely to anger click again and again.

However, if you do have a longer running request being executed, you'll probably need to introduce some form of progress notification in order to keep the user informed. For example, when you have a ribbon button that processes a bunch of records, perhaps have the button pop open a dialog which would display a progress indicator, and let the actual operation run inside the dialog's code. This way the user sees something "productive" happening immediately.

What's the cut off that determines if you need a progress indicator? The Nielsen Norman Group provides a good rule of thumb that if the operation is going to take longer than 10 seconds, you should provide a progress indicator, and consider displaying detail of changes in progress if possible. If the operation averages between 2 and 10 seconds, the recommmendation is to provide an indeterminate progress indicator.

In Summary

You should (almost) never be using synchronous service calls. 99.99% of the time you can, with a little bit more elbow grease and human processing power, accomplish the same exact thing with the application of an asynchronous pattern.

Topics: Microsoft Dynamics 365

Dynamics 365 Demo Video: Auto Capture

Today's blog post and video were created by Bryson Engelen, Sales Engineer at Sonoma Partners.

I'd like to share one of my favorite features of Dynamics 365 in this demo video.

Auto Capture lets you see emails relevant to an Account or Contact from within Dynamics 365 before they are tracked into the system.

Dynamics 365 now finds email messages within Microsoft Exchange to or from relevant email addresses and displays them right against the related records in Dynamics 365. Then, with just a click, you can move them from the personal intelligence of your inbox up to the collective intelligence of Dynamics 365, making them available to your team and for use by other Relationship Insights features.

You can still track messages in Dynamics 365 in all the ways that you could before, this just adds another way to bring emails from Exchange into Dynamics.  The emails found by auto capture show up inline with the rest of the record’s activities and are displayed on Contact, Opportunity, Lead, Account, Case, and Custom entities.

It should be noted that each email is private and visible only to you unless you choose to convert it to a tracked email.  It displays in gray with a dotted border and includes a Track link and private email label. Once you choose to track the email, all you need to do is click the track link to bring that message into Dynamics 365.  To see Auto Capture in action, watch the video below. 

Questions or comments? Drop us a line.

Topics: Microsoft Dynamics 365