Get SharePoint Document Location link on field on create in D365

I’ve been working on getting the SharePoint Document’s link to get back into D365 but looks like it can’t come back and get tagged to the record it was created from.

I tried to fire off a plugin on SharePoint Document record create, but in vain. Flow didn’t do justice since SharePoint Document entity doesn’t support Change Tracking.

So, I retrieved the Absolute URL of the “SharePoint Document Location” entity on it’s create itself so that I have the link once the record is created. And click that link to open the folder in SharePoint.

Workflow to wait and then fetch

So if you immediately make a call to retrieve the Absolute URL in the plugin code you’ve written on Create won’t work because Absolute URL gets created moments after the actual Location record is created unlike being passed in the execution context.

My approach is to fire the workflow on the create of the SharePoint Document Location record and Wait for 1 minute.

wfBody

After 1 minute, set off the flag to call the plugin and fetch the Absolute URL as shown below –

updateFlag

Retrieve Absolute URL in Plugin

You can use RetrieveAbsoluteAndSiteCollectionUrlRequest message to retrieve the SiteCollection URL and the Absolute URL of the document folder of the record

retrieveAbsolute

 

Working

  1. When you open the Document sub-grid on the record for the first time, a Document Location record is created –
    openForFirst
  2. The workflow designed above will run and fire off the plugin after 1 minute. The plugin will then make the message request go through to get you the Absolute URL as below –
    link2
  3. And probably you can use that link to open up the folder by clicking on the field that has this URL or send it across in email to internal users (whatever suits your requirements)
    linkInField
  4. It will open up the SP folder for that record and will have all the documents you attach in the Document sub-grid on the record.
    spFolder

Hope this helps!

Advertisements

‘Based on entity’ folder structure in D365 SharePoint Online Integration

When you configure SharePoint Online integration for your D365 entities, while setting up, you see an option to either proceed to enable feature based on entity or not.

featuredImage

And you’re not sure what it means. Let’s quickly see that it stands for.

I assume you know that you’ll need to go to Settings > Document Management > Document Management Settings to enable SharePoint integration for selected entities.

DocManagement

Now, let’s look at the difference between them.

Folder Structure based on Entity

When you select based on Entity, you get 2 options – Account and Contact. There’s no more options.

basedOnEntity

Now, when the above is setup and when you put documents under an Opportunity, see below how the documents will be stored in SharePoint.

  1. The Opportunity Printers has a parent Account called as ‘Adventure Works’.
    addToOppAnd you add Document to this Opportunity.
    addDocToOpp
  2. When I add documents under Opportunity Printers, on the SharePoint site, it will be like –
    folderStructureAsEntity

Folder Structure Not Based on Entity

Note: I’m doing this in another instance for demo purpose.

notAsEntity

  1. When you don’t select and proceed as is, and you go to the Opportunity Printers and add you Documents to the record as below.
    addDocToOpp2
  2. You can see unlike the one based on Entity, these Documents have Opportunity at the root level and not the Account which is that Opportunities’ parent.
    folderStructureNotAsEntity

Hope that was straight forward!