Following is the case
We have Sharepoint integrated with Dynamics 365.
Sales person created an order is CRM and uploads a document against the Order in CRM.
We want a mechanism to trigger on file create/delete and update the relevant order with no of attachments against the order.
I am struggling to find the salesorder identifier (GUID) so i can update the record on file created/delete.
Secondly, is there a way to find how many files are available in Sharepoint for each CRM Record (salesorder)?
Could you please share a screenshot of the configuration of your flow?
Could you please share more details about your scenes?
Please share more details about your scenes so we could try to provide a proper workaround for you.
Scenario - A Salesperson creates an order in CRM against a Customer (Acccount). The Order is considered as complete only when the Work Order is attached/uploaded against the order. So we suggested to create a custom field (whole number) "No of Attachment" on SalesOrder entity to manage the number of attachments against the order. We are open to new suggestions.
Following are the configurations
Dynamics CRM 365 Online
Folder Path - account/AccountName/salesorder/SalesOrderName_SalesOrderGuid/
account/Chambers of Sample/salesorder/ORD-36762-Ch303-Chambers of Sample_A18F392C6D20E811A95600224800375D/
Document Location contains the following info
Relative URL - SalesOrderName_SalesOrderGuid
Eg. ORD-36762-Ch303-Chambers of Sample_A18F392C6D20E811A95600224800375D
Regarding - Lookup field that Contains the SalesOrderId (Guid)
Current Flow Setup
We used two variables
FolderName - Relative URL for the Attachment
No of Attachments - to retrieve the current attachment count from SalesOrder
Trigger - When a file is created
Split the Folder Path by '/' (Folder path is Dynamic Content from Step:1)
"Chambers of Sample",
"ORD-36762-Ch303-Chambers of Sample_A18F392C6D20E811A95600224800375D",
Set FolderName by assigning the 4th Array Element
"ORD-36762-Ch303-Chambers of Sample_A18F392C6D20E811A95600224800375D"
List of Records
Find Top 1 Document Location by Relative URL. This record contains the SalesOrderId (Guid) as Regarding.
Get the SalesOrder Record by Regarding (Step:6)
Assign the SalesOrder's "No of Attachment" to the local varilable
Increment the local variable by 1
Update the SalesOrder with "No of Attactment" (local variable)
This solution is working fine as expected. But I am looking for an alternative to search for number of attachment against the order rather than incrementing the count by 1.
Another issue, when a file is delete, we are not able to reduce the number by 1 as the body of the trigger contains very minimum info as below
"DeletedByUserName": "Admin User",
Speakers, submit your sessions now! Call for speakers ends Feb. 10!
We've updated and improved the layout and uploading format of the Power Automate Cookbook!
Fill out a quick form to claim your user group badge now!
We've given our badges an overhaul and also added some brand new ones!
Learn how to build the business apps that you need.
Find out where you can attend!
Watch & learn from the Power Automate Community Video Gallery!