Recently while working on Field Service project, we got requirement to setup SharePoint integration where customer wanted to use Folder stricture based on the Account entity. By default entity based folder structure is not supported for work order entity so we used Flow to implement this requirement, in this article we are going to discuss the same.
Implement account entity folder structure for work order entity so that all the work order related documents is stored under parent customer folder hierarchy.
When I got this requirement, I thought it can be achieved using out of the box configuration but when I completed SharePoint integration setup and tested, I found , Dynamics 365 CE was not creating folder for work order entity under parent service account, instead it was creating work order folder under standalone work order document library. When I tried to upload document in child opportunity, it was creating opportunity folder correctly under parent account in SharePoint. When I was troubleshooting this issue, I found this KB Which explains why work order document is not create under account hierarchy because Work order entity have multiple N:1 relationship record with Account entity.
“With the exception of the opportunity and contract entities, a hierarchical folder structure will not be automatically created in SharePoint for entities that have more than one many-to-one (N:1) relationship with the parent entity.”
After identifying the issue, next step is to fix it with minimal efforts and Microsoft Flow came into my mind as I have used it earlier for SharePoint integration. let’s see how we can create Work Order structure under Account.
The whole Flow to create work order folder is divided into two parts, the first part is below where we added three steps:
1. First steps is to start flow when new work order record is created so we selected Create step from Dynamics 365 connector.
2. Second steps is to Get Record step to get service account record because we need customer name to for SharePoint folder path.
3. There is no direct option to create folder in SharePoint but we can use Create File option from SharePoint connector where we can upload dummy file, and it will setup folder for us
We have created SharePoint folder for work order under account it now, but Dynamics 365 CE SharePoint won’t use this folder unless we will setup Document Location record and that’s the tricky part. To create document library record, let’s first understand, how document location record is created in Dynamics 365 in case folder structure hierarchy. Here is the screenshot of the document location records, when we have uploaded document under opportunity created HIMBAP customer.
As you can see in above screenshot, 1 record is created for the Account folder in the SharePoint site location. After that we have record 2 created for HIMBAP account under the Account location. Further Opportunity record is created under the Account folder because we have implemented folder hierarchy structure. After that Demo opportunity record is created which referred Opportunity document location record, so these records are related using following sequence.
And we need to implement the same sequence for our work order entity. We will discuss document location part in the next article, so stay tuned !!