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. This is our second article, please check first article before reading this article.
Implement account entity folder structure for work order entity so that all the work order related documents is stored under parent customer folder hierarchy. I earlier article we discussed how document location record is created in Dynamics 365 CE when folder structure is implemented using out of the box SharePoint integration. Now let’s first create variable to hold folder path for the work order and Account. We can click on + New Step button to and search for variable. We can setup variable like following.
In above screen we are using the same combination of work order number + GUID formula and Account Name + GUID formula that we used while creating SharePoint folder in earlier step.
Next we are going to retrieve all the document location records based on the account. We can click on + New Step and can add List Record step and can configure it like following.
After this we need to process these record so need to add Apply to each control and further based on document location record we need to check if Account folder exists already or not.
Here we are checking length of the result like following
If record not present for the Account first we need to create Document location record for the Parent Account using SharePoint location record and then we need to Create Work order Parent folder location record based on the SharePoint location record and finally we need to create child work order record based on the work order path variable.
Once both the parent record created we need to finally create Child work order folder using following configuration.
And if parent document location already exists for Account, we can create only Parent Work order Folder and Child Work order folder using create record steps just like we did in above step. We need to add these steps if no part condition. Click on Save and test your flow by creating a work order for the account and you will be able to see work order created under service account like following
I hope it will help someone, Stay tuned for more Dynamics 365 CE Contents !!