Dynamics 365: JavaScript Enabled Button For Box.com Using KingswaySoft And Ribbon Workbench – Part 1


Recently I was tasked with devising a way where our end users could click a button located on an entity form in Dynamics 365 that would launch our Enterprise Box.com file sharing site.  This button would be dynamic, driven via JavaScript, and would open the related Box.com folder location that would be dependent upon the entity record the button was initiated from.

There seems to be endless amounts of help documentation and blog posts about how to setup, interact, and manipulate various pieces of the out-of-the-box feature called SharePoint Document Locations.  Unfortunately for me, I’m unable to use the default out-of-the-box functionality of SharePoint Document Locations.  Instead, what I want is to utilize is my own cloud drive storage solution; for example Box.com.  However, there doesn’t seem to be much help on the subject, nor are there any documented solutions with other third party cloud storage products.  So I ended up just created my own.

So the goal of this article is to walk you through how one can use the current Dynamics 365 SharePoint Document Locations in a way that will allow you to keep the basic structure but instead, access an external cloud drive storage system.  This first article will describe the requirements, helpful FetchXml queries, along with how to add the necessary pieces to SharePoint Document Locations.  I will not walk you through how to setup and configure it from scratch as there are plenty of articles on that subject.

Series Links Parts 1-4:

Problem

Now comes the fun part, the problem.  As I mentioned before the problem really stems from the fact that we store our related files in an online storage solution other than Microsoft’s own SharePoint system.  However, the SharePoint Document Location is a ready-to-go document storage solution that I can use with really any 3rd party source.  It just needs to be fudged a little to work correctly.  What I needed to do was devise a way to pull and parse that 3rd party online source (Box.com) file and folder information and filter for valid folders where I could in turn build the necessary Absolute Urls to be stored and later accessed in Dynamics 365.

Microsoft has already created a fully fleshed out system with everything I need so I don’t want to reinvent the wheel.  Once all my Absolute Urls are in Dynamics 365.  I’ll just need to create a button and place it on various entity forms so that when an end user clicks on it, the JavaScript behind that button will determine what Absolute Url stored in the SharePoint Document Location is the correct one, and open up the correct folder location in my 3rd party storage solution.  If one doesn’t exist, no worries, just drive that user to the root folder of your 3rd party online storage solution so they can create one.

D365-FinalButton

Steps

  1. Use SSIS (SQL Server Integration Services) to download, parse, and store online folder/file information
  2. Determine what is a valid folder
  3. Store that information in a local database and build necessary urls for upload
  4. Push urls to Dynamics 365 SharePoint Document Locations
  5. Create and bind a dynamic button using Ribbon Workbench and JavaScript that takes the end user to the correct folder in your 3rd party online storage solution

Getting Started

In order to get things started I needed to make sure I had a few tools.  Listed below are a few things you’ll need to get the ball rolling.  Depending upon your 3rd party online storage solution and level of expertise you may deviate a bit from the list below.

Tools:

I use Microsoft Visual Studio 2017 at the moment for building my Microsoft SQL Server Integration Services (SSIS) projects.  I have installed the SQL Server Data Tools (SSDT) for Visual Studio and have provided the link for version 2017 and 2019 above.

Next, if you have never used XrmToolBox then I suggest you stop reading this article and get yourself familiar with that tool as it’s probably one of the most popular tools out there at the moment when dealing with Dynamics 365.  It contains an assortment of community driven plugins that one can install for solving various problems, administration, or for gathering information from your Dynamics 365 environment.  The plugin that we’ll be using to create our button and bind JavaScript to handle the logic is called Ribbon Workbench 2016.  I’ve been using this for quite some time as it’s a very powerful layering tool.

As for gathering the required data from your online storage solution (Box.com) and then uploading the finalized data to Dynamics 365 Online I’ll be using the a 3rd party tool called KingswaySoft Ultimate Toolkit.  You can download and use this toolkit in conjunction with SSIS in a development environment for free.  I realize if something like this was setup and then published to a production environment then of course you would need to buy a license.  However, for demoing purposes it serves its need, although any tool will work.  The point is to get the necessary field information from whatever online cloud storage solution you are working with into a local or online database system where one can stage and then push that data to Dynamics 365.

Dynamics 365 SharePoint Document Location Setup

First we need to setup a few things in Dynamics 365 so that when we push our Absolute Url from our intermediate custom SQL database to Dynamics 365, everything will work as designed.  First navigate to your Settings > Customizations screen in Dynamics 365.

D365-SettingsDocMgmt

Next, click the SharePoint Sites link.

D365-DocMgmt

Create a Site Collection

Click the New button and create a site collection that will be referenced with your online storage solution.  Below is a final view of what your site collection might look like.

D365-SiteCollections-Box

A view of the Active SharePoint Sites defined in Dynamics 365 is shown below.  Although the Box Site Collection is invalid we really don’t care.  It’s there for filtering and categorization.  Remember, we aren’t using the site collection so that we can click and manage our 3rd party online storage solution from within Dynamics 365. We are simply using the schema and metadata already built into Dynamics 365 so as to not reinvent the wheel safeguarding our published Absolute Urls.

D365-SiteCollections

  • sitecollectionid=[{YOUR_SITE_COLLECTION_ID_GUID}]
    • This is not required but useful in Dynamics 365, especially if we have identical Absolute Urls in our system but stored in different site collections.
    • Use the FetchXml query defined further down in this article to retrieve the id.
  • regardingobjecttypecode=1 (account entity)
    • This is required by Dynamics 365 when creating a record entry into the SharePoint Document Location entity.  We really only need to create Absolute Urls for the account entity.
    • Here is a cheat sheet for object type codes
  • servicetype=0
    • Not sure what this is used for, however seems to be in a lot of other help documentation.  I don’t believe it’s required nor have a found a different value other than 0, so why rock the boat.

If you were to create Relative Urls and use the SharePoint Document Location as intended without a 3rd party online storage solution then these two values would also be required.  Since we aren’t going that route you can ignore these below.

  • parentsiteorlocation=[{YOUR_SITE_COLLECTION_ID_GUID}]
  • parentsiteorlocationtypecode=9508 (sharepointdocumentlocation entity)

A view of the Active Document Locations defined in Dynamics 365 with Absolute Urls uploaded for use with our Ribbon Workbench button.

D365-ActiveDocumentLocations

Useful Fetch XML Queries

Below are FetchXml queries that can be used in conjunction with XrmToolKit and the FetchXml Tester plugin.

XrmToolKit-FetchXmlTester

You’ll need to run the first one to retrieve the sharepointid field value.  I hard-coded it into my JavaScript file that I’ll show you in a later post for the series since the sharepointid will never change.  It’s also helpful for filtering out duplicate Absolute Urls tied to different Site Collections that may exist in your system but have no relation to this project.  The latter command displays the most recently created SharePoint Document Location records, which will come in handy when debugging potential issues later on.

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" >
    <entity name="sharepointsite" >
        <all-attributes/>
    </entity>
</fetch>

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" >
    <entity name="sharepointdocumentlocation" >
        <all-attributes/>
        <order attribute="createdon" descending="true" />
    </entity>
</fetch>

Final Thoughts

This project was rather large and crosses over many different technologies.  Keeping the topics organized in a way that makes sense to both myself and the reader was by far the most challenging part of writing this 4 part series.  Thank you for sticking with me through this first part as I walked you through the problem at hand, tools, project requirements, helpful FetchXml queries, and how to setup your Dynamics 365 environment.

In my next post I’ll walk you through how my 3rd party online storage solution is setup, my SQL database for staging, and then how I process that data from Box.com to Dynamics 365 using a free for development version of KingswaySoft Ultimate Toolkit.

Series Links Parts 1-4:

2 thoughts on “Dynamics 365: JavaScript Enabled Button For Box.com Using KingswaySoft And Ribbon Workbench – Part 1

  1. KingswaySoft January 15, 2020 / 10:35 am

    We are excited to hear that our software provided you with the support you needed to get the work done! Thank you for reaching out to our support team and for highlighting the benefits of using our solutions. We look forward to reading parts 3 and 4!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s