Sonoma Partners Microsoft CRM and Salesforce.com Blog

Ins and Outs of App Deployment Using Microsoft Intune

Today’s blog post was written by Marty Diamond, Senior System Administrator at Sonoma Partners.

Here at Sonoma, we promote a highly mobile workforce. Like other businesses, this means distributing internal apps to phones and tablets not owned by the company. Many mobile device management solutions have risen to assist with this challenge. We’ve used a handful of these with varying degrees of success. Recently, we have been piloting Microsoft’s Intune system, a part of Microsoft’s Enterprise Mobility Suite. Intune is interesting as a significant portion of it is dedicated not just to device management and compliance but application management, which offers many benefits to us.

Before delving too far into it, I should say that while Intune is a very flexible platform for managing a fleet of mobile devices, Sonoma’s use case is almost entirely dedicated to application distribution and updating. We have few company-owned mobile devices that are used by our QA team, and thee have very few requirements placed on them. This makes Intune very appealing: we can use it to simplify management of our mobile applications and scale up if needed.

We began testing with a simple task: log into the management portal and add a device. Getting there is simple enough. Once you’ve started the trial and assigned a license, Intune becomes another administrative portal launched from your Office365 portal. You are greeted with a set of startup prompts to help you navigate the portal from creating a policy to setting up your “Company Portal” to get devices into management. Once this is complete, the dashboard begins to fill with data about any devices it is managing.

Marty post 1 v2

The first real step within Intune is to define a policy. This is where we ran into our first “gotcha.” While the wizard takes you through defining a policy and creating other policies, it does not mention anything about deploying those policies. Nor does it mention that, by default, the existing Default Security Policy is not deployed. Missing this deployment step freezes the whole process: no device can be added unless a default policy is deployed.

Marty post 2 v2

Once we got past that, we continued testing with device onboarding. This process is critical as the easier we can make it for our staff to access apps they need, the less IT overhead we need. This where Intune scores some more victories—as a part of Office365, it works with our existing SSO. We simply needed to grant users licenses. From there, they are free to download the Company Portal app and sign in. The device add process is similar to other MDM solutions. It will ask the user for permissions to perform the functions it needs (management certificates for iOS, device administrator for Android, etc).

Notice that the Company portal app allows for easy app discovery and management. As long as they meet deployment criteria, users can find easily find apps by category. They can also see what other devices they have enrolled and if those devices are compliant. Each licensed Intune user is entitled to up to 5 devices (admins can limit this further).

For us, the star of the show was in app deployment. The Apps section does exactly what we need it to: deploy apps and keep them updated on our schedule.  The first step is to add an app. Much like policies, the process here is to add it and then deploy it. 

Marty post 4 v2

The Add App function launches a ClickOnce application that allows you to upload an app directly to Intune, hosted an external link, or—for iOS only—managed from the App Store. This same application is used to manage existing deployments. From this ClickOnce application you can change what types of devices can run the app (in the case of iOS universal apps), rename the apps, and keep apps updated. This was critical for us. Once a user has downloaded an app from Intune, they will then always have the latest version of that app on their device. The same is true for any apps we require the install for. One note here is that apps deployed to device groups that are required installs can take several hours after being upload to be deployed. The same is true with app updates. This delay does not appear to exist for apps deployed to users that are requested through the company portal.

In a lot of respects, Intune has more in common with System Center than other established MDM products. For example, when you want to deploy an app to groups of devices, you only have the options to Install or Uninstall. You can only make an app available to people via the portal by deploying to a group of users. While not immediately clear, this methodology makes a lot of sense: you might have groups for tablets and phones but deploying a universal app to a user allows someone with an iPhone and an iPad to get the app as needed without the need for two separate deployments.

Some other notes to keep in mind when considering Intune:

  • Intune supports direct connections to Exchange and SCCM. While we don’t employ these at Sonoma, leveraging them can give you more centralized control over devices.
  • Intune is smart about app deployments. For example, f you deploy an APK file to the “All Mobile Devices” group and mark it a required install, it won’t try and deploy to iOS devices or Windows machines. Keep this in mind when deciding how best to deploy your various mobile applications.
  • In our testing, sign-ins timed out very frequently, even in the Company Portal app (though the login itself is cached). This is a nice security measure but may cause confusion and you will want to communicate that to your users. 

Learn how to use Voice of the Customer in this guide

Topics: CRM Best Practices Microsoft Dynamics CRM 2016 Microsoft Dynamics CRM Online

Did They Get the Bang for Their Buck?

Today's blog post was written by Kristie Reid, VP of Consulting at Sonoma Partners.

Since the inception of Salesforce and Microsoft CRM, both companies have made investments to add huge pieces of functionality quickly through acquisitions.

This has made our jobs as CRM consultants exciting as the platforms continue to expand and both organizations continue to show their dedication to the products. However, in our quest to stay on top of all of the latest and greatest technologies, I thought it would be interesting to reflect on the success of each of these acquisitions.

Note: This post only goes back 5 years, and I’ve only included notable acquisitions that have impacted the CRM user experience – I did not get in-depth with all 50 products Microsoft and 28 products Salesforce has bought in that time.

Here is a chronological order of recent purchases with my assessment of the results of each purchase as it pertains to CRM:

407 acquisition blog graphic.2 v2

In general, really interesting stuff for both the CRM platforms and the companies that get bought and integrated into these two amazing companies. We know it’s hard to keep up with everything going on and will continue to keep you informed of any further developments!

Three Steps to CRM Success

Topics: CRM for Manufacturing CRM for Professional Services CRM Platform Selection CRM Upgrade Microsoft Dynamics CRM 2016 Microsoft Dynamics CRM Online Microsoft Dynamics Marketing Salesforce.com

Microsoft PSA - The More You Know

Today's blog post was written by Principal Consultants Nick Costanzo and Jeff Meister.

For today's blog post, we return to our "The More You Know" series after having spent some time under the hood of Microsoft's new Project Service Automation (PSA) solution. In a previous post, we covered a lot of the high-level features available in the system. Now that the solution is publicly available, we want to take some time to explore some of the feature functionality a little more in-depth.

As stated in our previous post, Microsoft's PSA Solution is an end-to-end solution which covers the entire customer life-cycle for delivering professional engagement; today we will start at the beginning and focus on Opportunity Management within PSA.

Sales Process Overview

We'll start with a quick review of a sample Sales Process within a professional service organization and the associated tasks that come with each phase.

Psa more you know image 1

Now that the sales process has been defined, let's look at what Microsoft's PSA solution has to offer for implementing a Sales Process.

Qualify

PSA takes the native Opportunity and extends it to support the ability to sell both Project and Product components. On the new Opportunity: Project Information form you can:

  • Itemize based on your organizations offerings (this includes not only a Services estimate, but also Expenses and Products).
  • Track probability to close and estimated close date as you would with native CRM.
  • Define Sales and Stakeholder team as you would with native CRM.

Psa more you know image 2

Quote

At this stage, the solution allows for high-level estimation based on a proposed delivery plan. Using the new Quote: Project Information form, you can view:

  • Profitability and Pricing measurements based on resource roles assigned as part of the delivery plan.

Psa more you know image 3

  • Billing methods and invoice schedules are also defined, including support for Fixed Price or Time and Material billing.

Psa more you know image 4

  • Comparison to customer budget is also displayed by Quote line, to ensure your project is rightly sized for your client.

Psa more you know image 5

Project Delivery Estimate

At this point of the Sales Process, a detailed project plan can be created and applied to the quote. With this plan, we are able to provide:

  • Resource mixing based on defined groups with the company.
  • Costing and Profitability calculations.
  • Validation across customer expectations.

Psa more you know image 6

Confirm Quote

Now that estimate has been completed by Delivery, we are able to:

  • Confirm the quote with a bottom-up estimate based on the detailed project plan.
  • Invoice scheduling based on billing method (Fixed Price or Time and Materials) for each quote line.

Psa more you know image 7

  • Generate a SOW based on the details validated throughout the Sales Process.

Psa more you know image 8

Now that the deal has been won, we are at a good stopping point. We have also transitioned very nicely into our next post which will be a more detailed look into the Project Estimation process…stay tuned!

Learn how to use Voice of the Customer in this guide
Topics: CRM Best Practices CRM for Professional Services Microsoft Dynamics CRM 2016 Microsoft Dynamics CRM Online

Privilege Error, Administrative Mode, & Form Layout Reminders

Strange title…you probably wonder how this ties together. Well, let's start with a little [true] story.

Yesterday, one of my colleagues was unable to access any of her records in CRM, but was working fine the day before. It was an odd conundrum as nothing *should* have changed.

  • The first step was look to ensure she had valid security roles. Yup…roles still there. [hint: this should have been enough for us to deduce the problem, but we tried a few more things before we figured it out.]
  • We removed all of her roles and the re-added them, hoping maybe it would reset her account. No luck!
  • She tried to access CRM on another machine, same results.
  • We then removed her roles and sure enough, she got the expected can't access CRM at all.

That result finally tipped us to the problem…

She could get into CRM but not access any records meant it was a license problem. Sure enough, looking closer at her user record, her Access Mode was Administrative and she was set to restrictive access. We merely flipped back those fields to their appropriate values, and she was back in business.

Now, in hindsight, we should have checked the license first (or at least second), but it didn't jump out at us as nothing should have changed with it. So, if your user can get into CRM but not see any entity records, look at her license type immediately.

But, I was curious as to why/how it was changed. This lead me to check the audit logs and I discovered that the day before, another colleague changed her license type. After a quick chat, it turns out she was merely updating her employee referrer value, and must have accidentally changed those fields. Weird, but as shown in the screenshot below, it was pretty easy to see how that could have happened.

SNAGHTML1287f7ee

We have definitely seen that users can inadvertently change values as they tab or click through the form, and this exactly what happened here.

I have no idea how the Employee Referrer field ended up in the CAL section. Was probably an oversight during our upgrade. Note: we have already relocated that field. Smile

The other item to address is why users are able to update Access Mode, Restricted Access Mode, and License Type. That should really more of a System Administrator task. Unfortunately those fields are not eligible for Field Level Security. So, we used our Dynamic Forms tool to secure those fields from all users except system administrators. Download our free community version of Dynamic Forms if you would like to do this yourself. If you don't use code/tool to protect these fields, consider moving those fields to a section away from the main parts of the form.

This situation provides a great reminder to consider your form layout and ensure fields are in the best possible location for discoverability and access, but also in cases like this we should have done a better job of preventing accidental changes to critical fields.

Topics: Microsoft Dynamics CRM 2016 Microsoft Dynamics CRM Online

Save My Data! CRM Online Backup & Restore

With the Dynamics 2016 Spring Release for CRM Online, a much anticipated feature for CRM Online has finally been rolled out.  This is the ability for the end user to be able to manage database backups, and restore a backup to your Online instance whenever you want.  Previously customers had to engage Microsoft support to do this for them, but now they’ll be able to manage this process on their own.

Details

There are no size limitations to the backups that can be taken (in case you have a large CRM database) but just know that the size does affect how long the backup and restore will take. 

In the O365 Admin center, when looking at your CRM instances table, you’ll see a new “Backup & Restore” link/tab that will take you to the area where the backups are taken, and where you would restore a backup to an instance.  From here you can also see when the last backup was performed for each instance.

image

Clicking on the “BACKUP & RESTORE” tab will bring you to the backup and restore home of the CRM Admin center where you can see a list of all the backups per instance you select in the drop down.  This is also where you can take different actions:  create a new user backup, edit an existing user backup, delete an existing user backup, and restoring a backup to a sandbox instance.

image

Creating a Backup

When you go to create a backup, you have the ability to provide a label and description for your backup.  This is the same dialog that will appear when you go to edit an existing backup allowing you to modify the name and description after you initially create it.

image

Backup Locations

With this new feature, users will only be able to backup to the CRM Online Server.  They’re currently not able to backup to any local location or anywhere in Azure.

The backups to the CRM Online Servers (Microsoft Data Centers) will be kept for 3 days.  Backups that are stored in CRM Online can be full backups (system backups) or incremental backups (user backups).  These are explained more below.

The backups themselves (system or on-demand user backups) do not count against your CRM Online storage space even though they’re backed up to the CRM Online Servers.

Backup Types:

The two following backup types are available for the CRM Online database:

  • System Backups
  • User Backups

System backups happen daily and are full backups.  What time of the day that they occur on cannot be confirmed and may vary, but they will happen at least once a day.  These will live on the CRM Online Servers, and will persist 3 days.

User Backups are incremental backups and therefore should backup and restore quicker.  These will also persist for 3 days.  There currently isn’t a limit to how many on-demand user backups you can take.

Restore Process

The backups themselves are encrypted, and you’re only able to restore back into a Sandbox instance.  If you want to restore to a Production instance, you’ll first need to convert the Production instance to a Sandbox instance, and then perform the restore.  The restore button will be grayed out for Production instances.

image

However, if you have to restore into a production instance, you can edit that instance to change it’s type to Sandbox, and after you do so, you’ll see the restore button in blue as in the screenshot in the Details section above.  Clicking on the restore button will pop the dialog that allows you to change the target to restore into.  Again this will only list sandbox instances.

image

image

image

During a restore, the instance you’re restoring into cannot be used.  Users will not be able to access the instance.  A good practice that’s supported would be to take a backup just before your CRM Online org is to be upgraded, and then if the upgrade fails for some reason (breaks some functionality), you can restore back to the backup taken which will restore you back to the previous version of CRM Online.

Delete Backup

Another action you can take on a backup in the backup and restore area is deletion of a user created backup.  Remember that after 3 days, the backups will be deleted automatically (this is shown in the “Expires On” column in the list of backups).  However a user may want to manually delete backups to clean up their list of user initiated backups.

image

Limitations

With this new feature like all new features, come some limitations:

  • This is only available for CRM Online 2016 Update 1
  • You cannot take an On Premise backup, and restore it into your Online instance
  • Cannot backup your Online instance, and restore it to an On Premise org for reporting purposes
  • There is no API support
  • There is currently no ability to schedule backups (other than the daily system backup that’s taken automatically once a day)

Even with these limitations it’s great to see some more power coming to the CRM Online customers hands.  I’m sure Microsoft will continue to enhance this already powerful tool and maybe eliminate some of the current limitations in future versions.

For more information on this functionality, head over to Microsoft’s TechNet article.  As always, you can always Contact Us to help out with your CRM implementation.

How to get executives to pay attention to CRM
Topics: Microsoft Dynamics CRM Microsoft Dynamics CRM 2016 Microsoft Dynamics CRM Online

How Mark Anthony Brands Revitalized Sales Culture with CRM and Mobility

Meet MABI

Mark Anthony Brands (MABI), the United States division of Mark Anthony Group (MAG), imports and distributes fine wine, premium beer, and specialty beverages. Due to alcohol distribution regulations, MABI can’t sell directly into accounts (e.g. bars/restaurants/stores). Instead, they rely on a network of distributors to facilitate these transactions. Field sales representatives (FSR) coordinate these operations and are crucial to how MABI does business. Overtime, business practices grew inconsistent and their sales tools outdated. The FSRs needed a mobile application to enhance the way they did business.

Mabi750x375

Time for a Change

Prior to this project, sales processes varied from region to region and from FSR to FSR. Practices for collecting/storing account information were piloted by single regions or teams, only to be abandoned shortly thereafter.

Their Leadership team aimed to provide the FSRs with a better means of doing their jobs, in order to secure better data and reporting capabilities. This shift in process would not only revitalize their sales culture but also spur enthusiasm from the FSRs by providing them with a new and unique means to reach their sales goals.

Objectives

The use cases for this project revolved around the tasks of the FSRs, which included:

  • Maintaining relationships with the account (bar/restaurant)
  • Quality assurance and evaluation of distributor performance via site surveys
  • Up-selling/cross-selling Mark Anthony Brands products

The plan?  A two-phased program including a Mobile Test Drive and mobile app development.

Download our free eBook: 5 Fundamental Features of Custom Mobile CRM Applications.

Post-Launch Life

The new mobile application – named, Mability (MABI + Mobility) – completely transformed the way the FSR team functions. With the new mobile CRM tool, they have better access to customer information in the field and an easier method for entering that transactional and account information. FSRs work more consistently than before with an implemented and defined sales process. Bonus: Mability features cross-device flexibility, providing endless opportunity taking the application to a tablet, an iPad, and beyond.

If you’d like to read more about the project, check out their customer success story here.

If you’d like to learn more about Sonoma Partners’ mobile applications, visit here.

New Call-to-action

 

Topics: CRM Best Practices CRM for Manufacturing Enterprise Mobility Microsoft Dynamics CRM Online

Need to export more records to Excel? We’ve got you covered with the OrgDBOrgSettings Editor!

With Dynamics, the default maximum record count to export to Excel is 10,000.  While this may work for a lot smaller business without a lot of data, it won’t work for most organizations.  An instance of this came up recently where a client of ours kept hitting the 10,000 record limit though they had many more records to export.

Typically in the past, if the customer was CRM OnPremise, you would be able to access this setting (along with the other OrgDBOrgSettings) using direct SQL.  Updating these values with SQL definitely wasn’t supported, but at least you could have conversations of updating the settings if you had individuals that knew what they were doing, or you created a support ticket with Microsoft to help you out.

However, if you had CRM Online, these settings weren’t available to you through the UI or even through SQL since with Online, you don’t have direct SQL access to your database.  What can you do?

That’s where the OrgDBOrgSettings editor comes in to play.  You can download the managed solution from this link.  The process to get it installed and use it is pretty simple.  Download the managed solution from that link, import it in as a normal solution into your environment, and then open up the solution.

From the configuration page of the solution, you’ll see the different settings that you have access to, what the default value is, what the current value is, and what the maximum value is (there are some limitations – you cannot update the MaxRecordsForExportToExcel to 500,000,000).

image

To edit a value, either double click on a row, or click the Edit link in the row for that setting.  When you do so, you have the option to set a custom value, or revert back to the default.  A checkbox at the bottom of the configuration page can be set or unset which will display a prompt to confirm the change upon making an update.

image

image

If you try to set a value over the maximum, you’ll get a message stating the requested change wasn’t saved, and the value will remain as it currently is.

image

This is a great utility to make supported updates to the OrgDBOrgSettings without having to reach out to Microsoft Support.  For a full list of all the settings that can be updated and a description of what the setting drives, navigate to this link.  Also, for more explanation on how to use the tool and what it can be used for, see this post from Sean McNellis who created the solution.  While this solution has been available for some time now, we’re hoping this is a great refresher to let you know what tools are available for free to help you make changes on your own.

Topics: CRM Best Practices Microsoft Dynamics CRM Microsoft Dynamics CRM 2013 Microsoft Dynamics CRM 2015 Microsoft Dynamics CRM 2016 Microsoft Dynamics CRM Online

Where are my Voice of the Customer Survey Responses?

I previously wrote a post about the basics of the new Dynamics CRM 2016 Voice of the Customer feature (also known as surveys for the common ear).

However, in my testing I’ve seen instances where my Survey Responses weren’t being created in Dynamics CRM. Remember, this feature is using Azure Web Services so that the Survey and Response Data are synchronized between Dynamics CRM and Azure to take the heavy survey workload off of your transactional Dynamics CRM database.  Therefore a delay in responses getting created is expected, but not a delay of hours or days like I had seen.

In order to see if your VoC jobs are running correctly, go to to Settings –> System –> System Jobs.  Perform a quick search for v* to pull back jobs that begin with the letter v.   What I saw were that there didn’t appear to be a system job running for the past month.

If you do come across this scenario, below are a few things you can do to get your Survey Responses to appear in CRM.

SNAGHTML2904ea6

Retrigger Response Processing from the Solution

The simplest fix is to navigate to the Voice of the Customer Solution (Settings –> Customization –> Solutions –> VoiceOfTheCustomer).  From the Configuration Page, you should see a link to “Retrigger response processing if responses are not received within 15 minutes of being completed” – click that and you should initiate a pull from Azure to pull this data back into Dynamics CRM.

image

Look at the System Jobs

Another thing you can do is open up your most recent Voice of the Customer System Jobs to see why they stopped.  In my example below it appeared as if a record in the system that was needed for the workflow was deleted.  In this example the check statement is checking the Voice of the Customer Configuration record so it appears as if that record may have been deleted at some point which caused the workflow to fail and stop processing.  This leads me to the next resolution step.

image

Delete and Recreate the Configuration Record

The Voice of the Customer Configuration record may have been deleted / manually recreated.  However, the only supported way for the Voice of the Customer solution to successfully process and return survey results to Dynamics CRM is to have the configuration record created from the Voice of the Customer Solution. 

Therefore if you have a Configuration record currently (which may had been manually created by someone), you need to first off delete this Configuration record. 

Note:  Before you do so, make note that when you delete this record and recreate it, you’ll need to recreate your surveys as the existing surveys will no longer work.  They’ll work in a sense that users will be able to hit them and fill them out, but results will no longer ever be returned to them.  This probably isn’t a big deal because the reason you’re going through this troubleshooting is because the records weren’t being returned in the first place.

Navigate to the solution in Settings –> Solutions –> Voice of the Customer.  On the Configuration tab of the solution, go through the same process you did when you initially setup Voice of the Customer which is check off the agreement to the terms and conditions, and then click on Enable Voice of the Customer. 

image

If you navigate to System Jobs once again, and filter on those that start with v*, you should see the workflows running successfully periodically and your survey responses should start to flow in for your new survey.  Remember, your old survey and workflows you created with the old survey email snippet will need to be recreated so new survey responses can start to be processed.

image

Topics: Microsoft Dynamics CRM Microsoft Dynamics CRM 2016 Microsoft Dynamics CRM Online

Microsoft Text Analysis and CRM–Tracking Client Sentiment

Microsoft has released a set of intelligence APIs known as Cognitive Services which cover a wide range of categories such as vision, speech, language, knowledge and search.  The APIs can analyze images, detect emotions, spell check and even translate text, recommend products and more.  In this post I will cover how the Text Analysis API can be used to determine the sentiment of your client based on the emails they send.

The idea is that any time a client (Contact in this case) sends an email that is tracked in CRM, then we will pass it to the Text Analysis API to see if the sentiment is positive or negative.  In order to do this, we will want to register a plugin on create of email.  We will make the plugin asynchronous since we’re using a third party API and do not want to slow down the performance of the email creation if the API is executing slowly.  We will also make the plugin generic and utilize the secure or unsecure configuration when registering the plugin to pass in the API Key as well as the schema name of the sentiment field that will be used.

Below is the constructor of the plugin to take in either a secure or unsecure configuration expecting the format of “<API_KEY>|<SENTIMENT_FIELD>”.

Next is the Execute method of the Plugin which will retrieve the email description from the email record and pass it to the AnalyzeText method.  The AnalyzeText method will return the sentiment value which we will then use the populate the sentiment field on the email record.

Then we have the AnalyzeText method which will pass the email body to the Text Analysis API which then returns the sentiment value.

And finally the classes used as input and output parameters for the Text Analysis API.

Now register the plugin on post-Create of Email with the Text Analysis API Key and the schema name of the sentiment field either in the secure or unsecure configuration

image

Now when an email is created in CRM, once the asynchronous job is complete, the email record will have a Sentiment value set from a range of 0 (negative) to 1 (positive).

image

The sentiment field on the email record can then be used as a calculated field on the contact to average the sentiment values of all the email records where the contact is the sender to track the sentiment of your clients based on the emails they send you.

Topics: Microsoft Dynamics CRM Microsoft Dynamics CRM 2015 Microsoft Dynamics CRM 2016 Microsoft Dynamics CRM Online

Building CRM Web Resources with React

Web Resource Development

Microsoft Dynamics CRM has allowed us to develop and host custom user interfaces as Web Resources since CRM 2011.  Since then, the web has exploded with JavaScript frameworks.  In addition, browsers have started to converge on standards both in JavaScript object support and CSS.  In short, its a great time to be building custom user interfaces on top of Microsoft Dynamics CRM.

Today we’ll be working with React, an emerging favorite in the JavaScript world.  React’s key benefits are its fast rendering time and its support of JSX.  React is able to render changes to the HTML DOM quickly, because all rendering is first done to JavaScript objects, which are then compared to the previously generated HTML DOM for changes.  Then, only those changes are applied to the DOM.  While this may sound like a lot of extra work, typically changes to the DOM are the most costly when it comes to performance.  JSX is a syntax that combines JavaScript and an XML-like language and allows you to develop complex user interfaces succinctly.  JSX is not required to use React, but most people typically use it when building React applications.

The Sample Application

To demonstrate these benefits, we’ll build a simple dashboard component that displays a list of the top 10 most recently created cases.  We’ll have the web resource querying for new cases every 10 seconds and immediately updating the UI when one is found.

CaseSummary

The files that I will be creating, will have the following structure locally:

CaseSummary/ 
├── index.html 
├── styles.css 
├── app.jsx 
└── components/ 
    ├── CaseSummary.jsx     
    ├── CaseList.jsx 
    └── Case.jsx

However, when we publish them as web resources in CRM, they will be simplified to the following:

demo_/
└── CaseSummary/ 
    ├── index.html 
    ├── styles.css 
    └── app.js

Other than including the publisher prefix folder, the main change is that all of the JSX files have been combined into a single JavaScript file.  We’ll step through how to do this using some command line tools.  There are a few good reasons to “compile” our JSX prior to pushing to CRM:

  1. Performance – We can minify the JavaScript and bundle several frameworks together, making it more efficient for the browser to load the page.
  2. More Performance – JSX is not a concept that browsers understand by default.  By converting it to plain JavaScript at compile time, we can avoid paying the cost of conversion every time the page is loaded.
  3. Browse Compatibility – We can write our code using all of the features available in the latest version of JavaScript and use the compiler to fill in the gaps for any older browsers that might not support these language features yet.
  4. Maintainability – Separating our app into smaller components makes the code easier to manager.  As you build more advanced custom UI, the component list will grow past what I am showing here.  By merging multiple files together, no matter how many JSX files we add to the project we just need to push the single app.js file to the CRM server when we are ready.
  5. Module Support – Many JavaScript components and libraries are distributed today as modules.  By compiling ahead of time we can reference modules by name and still just deploy them via our single app.js file.

Exploring the Source Code

The full source code for the example can be found at https://github.com/sonomapartners/web-resources-with-react, but we will explore the key files here to add some context.

index.html

This file is fairly simple.  It includes a reference to CRM’s ClientGlobalContext, the compiled app.js and our style sheet.  The body consists solely of a div to contain the generated UI.

app.jsx

Now things start to get more interesting.  We start by importing a few modules.  babel-polyfill will fill in some browser gaps.  In our case it defines the Promise object for browsers that don’t have a native version (Internet Explorer).  The last three imports will add React and our top level CaseSummary component.  Finally we register an onload event handler to render our UI into the container div.

components/CaseSummary.jsx

CaseSummary is our top level component and is also taking care of our call to the CRM Web API.  This is also our first look at creating a component in React, so let’s take a look at each function.  React.createClass will take the object passed in and wrap it in a class definition.  Of the five functions shown here, four of them are predefined by React as component lifecycle methods: getInitialState, componentDidMount, componentWillUnmount and rendergetInitialState is called when an instance of the component is created and should return an object representing the starting point of this.state for the component.  componentDidMount and componentWillUnmount are called when the instance is bound to and unbound from the DOM elements respectively.  We use the mounting methods to set and clear a timer, which calls the loadCases helper method.  Finally, render is called each time the state changes and a potential DOM change is needed.  We also have an additional method, loadCases where we use the fetch API to make a REST call.  The call to this.setState will trigger a render whenever cases are loaded.  We definitely could have made this component smarter by only pulling case changes, but this version demonstrates the power of React by having almost no impact on performance even though it loads the 10 most recent cases every 10 seconds.

components/CaseList.jsx

By comparison CaseList.jsx is pretty straight forward.  There are two interesting parts worth pointing out.  The use of this.props.cases is possible because CaseSummary.jsx set a property on the CaseList like this: <CaseList cases={this.state.cases} />.  Also, it is important to notice the use of the key attribute on each Case.  Whenever you generate a collection of child elements, each one should get a value for the key attribute that can be used when React is comparing the Virtual DOM to the actual DOM.

components/Case.jsx

The simplest of the components, Case.jsx outputs some properties of the case with some simple HTML structure.

Compiling the Code

We’re going to start with using NodeJS to install both development tools and runtime components that we need.  It is important to note that we’re using NodeJS as a development tool, but it isn’t being used after the code is deployed to CRM.  We’ll start by creating a package.json file in the same folder that holds our index.html file.

package.json

After installing NodeJS, you can open a command prompt and run “npm install” from the folder with package.json in it.  This will download the packages specified in package.json to a local node_modules folder.  At a high level, here are what the various packages do:

  • webpack, babel-*, imports-loader, and exports-loader: our “compiler” that will process the various project files and produce the app.js file.
  • webpack-merge and webpack-validator: used to help manipulate and validate the webpack.config.js (we will discuss this file next).
  • webpack-dev-server: a lightweight HTTP server that can detect changes to the source files and compile on the fly.  Very useful during development.
  • react and react-dom: The packages for React.
  • babel-polyfill and whatwg-fetch: They are bringing older browsers up to speed.  In our case we are using them for the Fetch API (no relation to Fetch XML) and the Promise object.

The scripts defined in the package.json are runnable by typing npm run build or npm run start from the command prompt.  The prior will run and produce our app.js file and the latter will start up the previously mentioned webpack-dev-server.  Prior to running either of them though, we need to finish configuring webpack. This requires one last config file to be placed in the same folder as package.json. It is named webpack.config.js

webpack.config.js

As the file name implies, webpack.config.js is the configuration file for webpack.  Ultimately it should export a configuration object which can define multiple entries.  In our case we have a single entry that monitors app.jsx (and its dependent files) and outputs app.js.  We use the webpack.ProvidePlugin plugin to inject whatwg-fetch for browsers that lack their own fetch implementation.  We also define that webpack should use the babel-loader for any .jsx or .js files it encounters and needs to load.  The webpack-merge module allows us to conditionally modify the configuration.  In our case we are setting the NODE_ENV environment variable to “production” for a full build and turning on JavaScript minification.  Finally we use the webpack-validator to make sure that the resulting configuration is a valid.

Deploying and Continuing Development

At this point all of the files should be set up.  To deploy the code, you would run npm run build and then deploy index.html, app.js, and styles.css as web resources to CRM. 

If it becomes tedious to keep deploying app.js to CRM as you make small changes, you can set up an AutoResponder rule in Fiddler to point at the webpack-dev-server.  Once this rule is in place, when the browser requests files like index.html and app.js from the right subfolder of the CRM server, Fiddler will intercept the request and provide the response from wepack-dev-server instead.  This way you can just save your local JSX files and hit refresh in the browser as you are developing.  Of course you need to be sure that you have started wepack-dev-server by running npm run start from the command line.  I have included an example for the rule I set up for this demo below:

fiddlerAutoResponder

With that you should be set to start building your own CRM Web Resources using React!

Topics: Microsoft Dynamics CRM Microsoft Dynamics CRM 2011 Microsoft Dynamics CRM 2013 Microsoft Dynamics CRM 2015 Microsoft Dynamics CRM 2016 Microsoft Dynamics CRM Online