Creating a Custom Repository in SharePoint Online and Its Integration with Dynamics CRM Online

As a user in Microsoft Dynamics CRM, we usually perform actions to create, Upload, View, and/or delete documents related to records. The preferred repository is a SharePoint location without the need to log in to a different site.

Microsoft has provided us with document management in CRM by using Server-based SharePoint Integration. It allows Dynamics CRM online and SharePoint Online to perform server-to-server connection.

The problem, though, with this out-of-box feature is, for every record that is created in Dynamics CRM and (assuming a document library is configured for the entity); while navigating to documents, an alert shows up indicating the folder name that will be created automatically.

Figure 2: Alert for automatic creation of folder in SharePoint

The repository name does not look very friendly and there is no control over its name during creation. It is very difficult to search the repository due to its very random name.

It should be a property on the entity that is unique. An auto number is a good example to start with. It can also be a combination of two fields that makes the name unique.

In this post, I am going to name the repository created as the Unique Auto Number ID created for the opportunity entity. Opportunity Numbers will read as "Neu-001," "Neu-002," and so forth.

Let us first understand what happens when the I click the Confirm button when prompted with "Create Folder" alert.

Figure 4: Dynamics CRM Document Location record

A SharePoint Document Location record in CRM is created in the background with following details:

Parent Site or Location: This is the location that is created automatically when doing CRM-SharePoint Integration.

Relative URL: This is the field that stores the repository name in CRM. A repository with this name is created automatically in integrated SharePoint. In my example, I need to populate this text with our Auto number, say, Neu-001.

Regarding: This is the reference to the CRM record.

Let me now write a plugin to create a SharePoint Document Location when the opportunity is created.

The plugin is registered when the opportunity is created. Once an opportunity is created, the plugin fires and creates a SharePoint Document Location. Navigate to the document from the opportunity and here is what I see now.

Figure 5: SharePoint Document Associated View

It looks like the CRM is trying to locate a folder in SharePoint. Because it does not find a respective SharePoint Location record and a matching relative URL, it is showing us a very friendly message to create/edit the folder name in SharePoint.

Additionally, if you notice, we do not get an alert to create a SharePoint folder at all.

So, it looks like, if we create a folder in SharePoint with matching "Relative URL" text, our problem is solved.

Now, I am going to create programmatically a folder with same Opportunity Number Text (the relative URL). This can be done by following two steps:

Registering a Microsoft Azure Service Bus Solution Endpoint and a step on creation of an opportunity.

Write a Windows Service to process the message posted in Service Bus and create Folder in SharePoint with desired Name.

Note: Having Windows Service does not seem to be a good idea because we are talking about CRM and SharePoint Online. Hence, creating an Azure role for this should be a fairly good idea. But then, the following code can always be used.

The following friendly repository name is created in SharePoint. This can be easily searched and is more readable.

Figure 7: SharePoint has created a friendly repository name

Conclusion

Although the CRM out-of-box feature for SharePoint integration does not provide flexibility and control to name each record folder created in SharePoint, the same can be achieved by creating a SharePoint Location record in CRM and by creating a folder in SharePoint separately and then associating the two. Seamless integration of Microsoft Azure and Dynamics helps post the created record message on service bus and a scheduler to read the message from Azure Service Bus and create SharePoint folder based on entity record attribute(s).

IT Solutions Builder
TOP IT RESOURCES TO MOVE YOUR BUSINESS FORWARD

Which topic are you interested in?

Mobile

Security

Networks/IoT

Cloud

Data Storage

Applications

Development

IT Management

Other

What is your company size?

What is your job title?

What is your job function?

Searching our resource database to find your matches...

Please enable Javascript in your browser, before you post the comment! Now Javascript is disabled.

Advertiser Disclosure:
Some of the products that appear on this site are from companies from which QuinStreet receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. QuinStreet does not include all companies or all types of products available in the marketplace.

Thanks for your registration, follow us on our social networks to keep up-to-date