diff --git a/samples/utility_flow_get_sharepoint_location_for_dataverse_record/README.md b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/README.md new file mode 100644 index 00000000..13d3d64f --- /dev/null +++ b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/README.md @@ -0,0 +1,177 @@ +# Get SharePoint location for Dataverse record + + + +## Summary + +SharePoint document management for Dataverse offers numerous [advantages](https://ludovicperrichon.com/synchronise-documents-in-between-dataverse-and-sharepoint), but while accessing documents and their locations via a model-driven Power Platform app is straightforward, retrieving them using Power Automate can be quite challenging. + +If you need to archive attached documents in a different location or send them all via email as attachments, you must first locate the SharePoint Online (SPO) library and folder associated with the entity. + +### Get SharePoint location for record + +The "Get SharePoint location for record" flow uses the **Document Location** Dataverse table to gather details about the attachment location, such as the `Relative URL` (folder name) and `sharepointdocumentlocationid`. + +Once SharePoint integration with Dataverse is configured for an entity, an entry pointing to the library in SharePoint is added. Note that the library name is based on the table logical name: + +![document location](./assets/documentlocations.png) + +Only when the first document is attached to a record, additional entry is created in the **Document Location** table , referencing a folder in the SharePoint library. The folder name is based on the record properties: + +![document location for a record](./assets/documentlocations2.png) + +The above values are not enough to access the SharePoint location where the documents are stored, but can be used in a call to the [RetrieveAbsoluteAndSiteCollectionUrl()](https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/reference/retrieveabsoluteandsitecollectionurl?view=dataverse-latest) Dataverse function to obtain the SharePoint Online site collection URL: + +`/api/data/v9.2/sharepointdocumentlocations(sharepointdocumentlocationid)/Microsoft.Dynamics.CRM.RetrieveAbsoluteAndSiteCollectionUrl()` + +The flow then executes a series of SharePoint REST api calls to obtain a full set of information, like + +| parameter name | description | example | +|-|-|-| +| `tenant_name` | the URL of the tenant's root site; also used as a hostname when retrieving SPO site [using GUID](https://learn.microsoft.com/en-us/graph/api/site-get?view=graph-rest-1.0&tabs=http#example-1-get-a-site-using-the-site-id). | `contoso.sharepoint.com` | +| `site_url` | The URL of the current SharePoint site, as defined in the `site URL` parameter. | `https://contoso.sharepoint.com/sites/XYZ` | +| `site_title` | Title of the current SPO site | `Project XYZ` | +| `site_id` | The `id` of the current SPO site in a `guid` format. | `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` | +| `web_id` | The `id` of the current SPO web object in a `guid` format. | `yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy` | +| `library_absolute_url` | The full URL of the library. | `https://contoso.sharepoint.com/sites/XYZ/idapps_externalcloudservice` | +| `library_name` | The `RootFolder`. Used in the URL, is generated automatically and cannot be changed by users. It can be changed with PowerShell.| `idapps_externalcloudservice` | +| `library_title` | The title of the library. This property can be changed by the user. | `The Archive Library` | +| `library_id` | Library's id in a `guid` format | `zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz` | +| `library_drive_id` | Used by Graph API when referencing libraries. | `b!S3SdNSBmTUGa4v5ffh_rslLJssoXH4xEuShkEO-uxKg9bblUMeoaTbQC5t69DJ-x` | +| `folder_absolute_url` | absolute url of a SPO library folder associated with the current teams channel | `https://contoso.sharepoint.com/sites/XYZ/idapps_externalcloudservice/test01_5437302CBC7A4D96AFD9BDFDAF15EF7F`| +| `folder_display_name` | display name of the folder; white spaces are not encoded | `test01_5437302CBC7A4D96AFD9BDFDAF15EF7F`| +| `folder_drive_id` | `driveItem Id` for the folder. Can be used in MS Graph API [Get driveItem](https://learn.microsoft.com/en-us/graph/api/driveitem-get) | `01JEVXUVBDVF6ZMUFRM5B34EGLOEDAUF5B`| +| `folder_id` | SPO list item id. Can be used in SharePoint REST API, or MS Graph API [Get listItem](https://learn.microsoft.com/en-us/graph/api/listitem-get) | `15`| +| `error_message` | The error message if any of the actions failed, or empty string. | `{"Error":"..."}` | +| `success` | | `True` or `False` | + + +## Applies to + +![Power Apps](https://img.shields.io/badge/Power%20Apps-Yes-green "Yes") +![Power Automate](https://img.shields.io/badge/Power%20Automate-Yes-green "Yes") +![Power BI](https://img.shields.io/badge/Power%20BI-No-red "No") +![Power Pages](https://img.shields.io/badge/Power%20Pages-No-red "No") +![Power Virtual Agents](https://img.shields.io/badge/Power%20Virtual%20Agents-No-red "No") +![Dataverse](https://img.shields.io/badge/Dataverse-Yes-green "Yes") +![AI Builder](https://img.shields.io/badge/AI%20Builder-No-red "No") +![Custom Connectors](https://img.shields.io/badge/Custom%20Connectors-No-red "No") +![Power Fx](https://img.shields.io/badge/Power%20Fx-No-red "No") + +## Compatibility + +![Premium License](https://img.shields.io/badge/Premium%20License-Required-green.svg "Premium license required") +![Experimental Features](https://img.shields.io/badge/Experimental%20Features-No-red.svg "Does not rely on experimental features") + +## Contributors + + +* [Kinga Kazala](https://github.com/kkazala/) + +## Version history + +Version|Date|Comments +-------|----|-------- +1.0|April 30, 2025|Initial release + +## Prerequisites + +The "[HTTP with Microsoft Entra ID (preauthorized)](https://learn.microsoft.com/en-us/connectors/webcontents/)" connector operates through a Microsoft 1st party trusted application. This application includes preauthorization for various Microsoft services and there is no need for administrators to explicitly grant consent for actions to be executed by the application on behalf of the user. +Microsoft also released a new version of the connector, the "[HTTP With Microsoft Entra ID](https://learn.microsoft.com/en-us/connectors/webcontentsv2/)", allowing administrators to grant discrete consent. + +Update the workflow to use the "HTTP With Microsoft Entra ID" connector, if required. + +## Minimal path to awesome + + +### Using the solution zip + +* [Download](./solution/solution.zip) the `.zip` from the `solution` folder +* Within **Power Apps Studio**, import the solution `.zip` file using **Solutions** > **Import Solution** and select the `.zip` file you just packed. +* Open the app in edit mode and make sure the data source **Data source name** is connected correctly. + +### Using the solution zip + +* [Download](./solution/solution.zip) the `.zip` from the `solution` folder +* Within **Power Apps Studio**, import the solution `.zip` file using **Solutions** > **Import Solution** and select the `.zip` file you just packed. +* When importing a solution, you will need to provide a connection reference to your Power Platform Environment. Ensure that the connection is created using the URL of your Power Platform Environment. + + ![Creating new connection](./assets/httpconnector.png) + + The value of "URL of the request" does not include a host name. The request URL will be created by combining the URL specified in the referenced connection with the API endpoint defined in the "URL of the request" field. + + ![Http Action](./assets/request.png) + +* After the solution is imported, configure the **Get Localized choice values** cloud flow, to be executed as a child flow. Configure the `run only` permissions, using the flow owner’s embedded connection: + + ![Run Only Users](./assets/runOnlyUser.png) + + Click on **Edit** link and change the connection in the **Connections Used** section + + ![Run Only Connection](./assets/runOnlyConnection.png) + +* Add a [service principal](https://learn.microsoft.com/en-us/power-automate/service-principal-support) as an additional owner to ensure business continuity. + +### Using the source code + +You can also use the [Power Apps CLI](https://docs.microsoft.com/powerapps/developer/data-platform/powerapps-cli) to pack the source code by following these steps: + +* Clone the repository to a local drive +* Pack the source files back into a solution `.zip` file: + + ```bash + pac solution pack --zipfile pathtodestinationfile --folder pathtosourcefolder --processCanvasApps + ``` + + Making sure to replace `pathtosourcefolder` to point to the path to this sample's `sourcecode` folder, and `pathtodestinationfile` to point to the path of this solution's `.zip` file (located under the `solution` folder) +* Within **Power Apps Studio**, import the solution `.zip` file using **Solutions** > **Import Solution** and select the `.zip` file you just packed. +* When importing a solution, you will need to provide a connection reference to your Power Platform Environment. Ensure that the connection is created using the URL of your Power Platform Environment. +* After the solution is imported, configure the **Get SharePoint location for record** cloud flow, to be executed as a child flow. Configure the `run only` permissions, using the flow owner’s embedded connection + + + +## Help + + + +> Note: don't worry about this section, we'll update the links. + +We do not support samples, but this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues. + +If you encounter any issues while using this sample, you can [create a new issue](https://github.com/pnp/powerapps-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=bug-report.yml&sample=YOUR-SOLUTION-NAME&authors=@YOURGITHUBUSERNAME&title=YOUR-SOLUTION-NAME%20-%20). + +For questions regarding this sample, [create a new question](https://github.com/pnp/powerapps-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=question.yml&sample=YOUR-SOLUTION-NAME&authors=@YOURGITHUBUSERNAME&title=YOUR-SOLUTION-NAME%20-%20). + +Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/powerapps-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=suggestion.yml&sample=YOUR-SOLUTION-NAME&authors=@YOURGITHUBUSERNAME&title=YOUR-SOLUTION-NAME%20-%20). + +## Disclaimer + +**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.** + + diff --git a/samples/utility_flow_get_sharepoint_location_for_dataverse_record/assets/documentlocations.png b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/assets/documentlocations.png new file mode 100644 index 00000000..9f6f24f2 Binary files /dev/null and b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/assets/documentlocations.png differ diff --git a/samples/utility_flow_get_sharepoint_location_for_dataverse_record/assets/documentlocations2.png b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/assets/documentlocations2.png new file mode 100644 index 00000000..7cdbbad7 Binary files /dev/null and b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/assets/documentlocations2.png differ diff --git a/samples/utility_flow_get_sharepoint_location_for_dataverse_record/assets/httpconnector.png b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/assets/httpconnector.png new file mode 100644 index 00000000..a94087cd Binary files /dev/null and b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/assets/httpconnector.png differ diff --git a/samples/utility_flow_get_sharepoint_location_for_dataverse_record/assets/request.png b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/assets/request.png new file mode 100644 index 00000000..00cd997e Binary files /dev/null and b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/assets/request.png differ diff --git a/samples/utility_flow_get_sharepoint_location_for_dataverse_record/assets/runOnlyConnection.png b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/assets/runOnlyConnection.png new file mode 100644 index 00000000..a09a575d Binary files /dev/null and b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/assets/runOnlyConnection.png differ diff --git a/samples/utility_flow_get_sharepoint_location_for_dataverse_record/assets/runOnlyUser.png b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/assets/runOnlyUser.png new file mode 100644 index 00000000..24faf3da Binary files /dev/null and b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/assets/runOnlyUser.png differ diff --git a/samples/utility_flow_get_sharepoint_location_for_dataverse_record/sourcecode/GetDataverserecordSPO/.gitignore b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/sourcecode/GetDataverserecordSPO/.gitignore new file mode 100644 index 00000000..ba59257a --- /dev/null +++ b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/sourcecode/GetDataverserecordSPO/.gitignore @@ -0,0 +1,8 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# msbuild output directories +/bin +/obj + +# MSBuild Binary and Structured Log +*.binlog diff --git a/samples/utility_flow_get_sharepoint_location_for_dataverse_record/sourcecode/GetDataverserecordSPO/GetDataverserecordSPO.cdsproj b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/sourcecode/GetDataverserecordSPO/GetDataverserecordSPO.cdsproj new file mode 100644 index 00000000..08665340 --- /dev/null +++ b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/sourcecode/GetDataverserecordSPO/GetDataverserecordSPO.cdsproj @@ -0,0 +1,54 @@ + + + + $(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\PowerApps + + + + + + + 7afdd233-bde3-4d67-91f7-5daa43bf2743 + v4.6.2 + + net462 + PackageReference + src + + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + + + + + diff --git a/samples/utility_flow_get_sharepoint_location_for_dataverse_record/sourcecode/GetDataverserecordSPO/src/Other/Customizations.xml b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/sourcecode/GetDataverserecordSPO/src/Other/Customizations.xml new file mode 100644 index 00000000..b9363fa0 --- /dev/null +++ b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/sourcecode/GetDataverserecordSPO/src/Other/Customizations.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + Microsoft Dataverse + /providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps + 1 + 0 + 0 + 1 + + + HTTP with Microsoft Entra ID (preauthorized) ExternalCloudService-f5993 + /providers/Microsoft.PowerApps/apis/shared_webcontents + When creating connection, use the url of your Power Platform Environment + 1 + 0 + 0 + 1 + + + SharePoint Online + /providers/Microsoft.PowerApps/apis/shared_sharepointonline + SharePoint Online connection reference + 1 + 0 + 0 + 1 + + + + 1033 + 1031 + + \ No newline at end of file diff --git a/samples/utility_flow_get_sharepoint_location_for_dataverse_record/sourcecode/GetDataverserecordSPO/src/Other/Solution.xml b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/sourcecode/GetDataverserecordSPO/src/Other/Solution.xml new file mode 100644 index 00000000..1fd410cd --- /dev/null +++ b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/sourcecode/GetDataverserecordSPO/src/Other/Solution.xml @@ -0,0 +1,98 @@ + + + + GetDataverserecordSPO + + + + + 1.0.0.0 + 2 + + KingaK + + + + + + + kk + 33987 + +
+ 1 + 1 + + + + + + + + + + + + + + + + 1 + + + + + + + + +
+
+ 2 + 1 + + + + + + + + + + + + + + + + 1 + + + + + + + + +
+
+
+ + + + + + + + + + + + + + + + + +
+
\ No newline at end of file diff --git a/samples/utility_flow_get_sharepoint_location_for_dataverse_record/sourcecode/GetDataverserecordSPO/src/Workflows/GetSharePointlocationforrecord-EFF48012-4F77-EF11-AC20-002248C9A7CB.json b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/sourcecode/GetDataverserecordSPO/src/Workflows/GetSharePointlocationforrecord-EFF48012-4F77-EF11-AC20-002248C9A7CB.json new file mode 100644 index 00000000..b0092f0c --- /dev/null +++ b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/sourcecode/GetDataverserecordSPO/src/Workflows/GetSharePointlocationforrecord-EFF48012-4F77-EF11-AC20-002248C9A7CB.json @@ -0,0 +1,1379 @@ +{ + "properties": { + "connectionReferences": { + "shared_commondataserviceforapps_1": { + "runtimeSource": "embedded", + "connection": { + "connectionReferenceLogicalName": "idapps_sharedcommondataserviceforapps_6b4f3" + }, + "api": { + "name": "shared_commondataserviceforapps" + } + }, + "shared_webcontents": { + "runtimeSource": "embedded", + "connection": { + "connectionReferenceLogicalName": "idapps_sharedwebcontents_f5993" + }, + "api": { + "name": "shared_webcontents" + } + }, + "shared_sharepointonline": { + "runtimeSource": "embedded", + "connection": { + "connectionReferenceLogicalName": "idapps_sharedsharepointonline_58e5f" + }, + "api": { + "name": "shared_sharepointonline" + } + } + }, + "definition": { + "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "$connections": { + "defaultValue": {}, + "type": "Object" + }, + "$authentication": { + "defaultValue": {}, + "type": "SecureObject" + } + }, + "triggers": { + "manual": { + "metadata": { + "operationMetadataId": "1361dbcd-dfd6-46cc-adb0-524a8b8391cb" + }, + "type": "Request", + "kind": "PowerAppV2", + "inputs": { + "schema": { + "type": "object", + "properties": { + "text": { + "title": "Record Id", + "type": "string", + "x-ms-dynamically-added": true, + "description": "Please enter your input", + "x-ms-content-hint": "TEXT" + } + }, + "required": [ + "text" + ] + } + } + } + }, + "actions": { + "Respond_to_a_Power_App_or_flow": { + "runAfter": { + "Scope:_Error_Handling": [ + "Succeeded", + "Failed", + "Skipped", + "TimedOut" + ] + }, + "metadata": { + "operationMetadataId": "cfbfcaf5-8a7b-4b2a-8b55-767f27ea3fa4" + }, + "type": "Response", + "kind": "PowerApp", + "inputs": { + "statusCode": 200, + "body": { + "tenant_name": "@body('Parse_JSON:_objResults')?['tenant_name']", + "site_url": "@{body('Parse_JSON:_objResults')?['site_url']}", + "site_title": "@{body('Parse_JSON:_objResults')?['site_title']}", + "site_id": "@{body('Parse_JSON:_objResults')?['site_id']}", + "web_id": "@{body('Parse_JSON:_objResults')?['web_id']}", + "library_absolute_url": "@{body('Parse_JSON:_objResults')?['library_absolute_url']}", + "library_name": "@{body('Parse_JSON:_objResults')?['library_name']}", + "library_title": "@{body('Parse_JSON:_objResults')?['library_title']}", + "library_id": "@{body('Parse_JSON:_objResults')?['library_id']}", + "library_drive_id": "@{body('Parse_JSON:_objResults')?['library_drive_id']}", + "folder_absolute_url": "@{body('Parse_JSON:_objResults')?['folder_absolute_url']}", + "folder_display_name": "@{body('Parse_JSON:_objResults')?['folder_display_name']}", + "folder_id": "@{body('Parse_JSON:_objResults')?['folder_id']}", + "folder_drive_id": "@{body('Parse_JSON:_objResults')?['folder_drive_id']}", + "error_message": "@variables('sErrorMessage')", + "success": "@{variables('bSuccess')}" + }, + "schema": { + "type": "object", + "properties": { + "tenant_name": { + "title": "tenant_name", + "x-ms-dynamically-added": true, + "type": "string" + }, + "site_url": { + "title": "site_url", + "x-ms-dynamically-added": true, + "type": "string" + }, + "site_title": { + "title": "site_title", + "x-ms-dynamically-added": true, + "type": "string" + }, + "site_id": { + "title": "site_id", + "x-ms-dynamically-added": true, + "type": "string" + }, + "web_id": { + "title": "web_id", + "x-ms-dynamically-added": true, + "type": "string" + }, + "library_absolute_url": { + "title": "library_absolute_url", + "x-ms-dynamically-added": true, + "type": "string" + }, + "library_name": { + "title": "library_name", + "x-ms-dynamically-added": true, + "type": "string" + }, + "library_title": { + "title": "library_title", + "x-ms-dynamically-added": true, + "type": "string" + }, + "library_id": { + "title": "library_id", + "x-ms-dynamically-added": true, + "type": "string" + }, + "library_drive_id": { + "title": "library_drive_id", + "x-ms-dynamically-added": true, + "type": "string" + }, + "folder_absolute_url": { + "title": "folder_absolute_url", + "x-ms-dynamically-added": true, + "type": "string" + }, + "folder_display_name": { + "title": "folder_display_name", + "x-ms-dynamically-added": true, + "type": "string" + }, + "folder_id": { + "title": "folder_id", + "x-ms-dynamically-added": true, + "type": "string" + }, + "folder_drive_id": { + "title": "folder_drive_id", + "x-ms-dynamically-added": true, + "type": "string" + }, + "error_message": { + "title": "error_message", + "x-ms-dynamically-added": true, + "type": "string" + }, + "success": { + "title": "success", + "x-ms-dynamically-added": true, + "type": "boolean" + } + } + } + }, + "description": "Return library Id, Name (Root Folder Name, used in URLs), Title (Display Name) and FolderName, where documents for the record are stored" + }, + "Initialize_variable:_objResults": { + "runAfter": {}, + "metadata": { + "operationMetadataId": "f890389c-06b1-42c2-a27f-9b31a7d158fa" + }, + "type": "InitializeVariable", + "inputs": { + "variables": [ + { + "name": "objResults", + "type": "object", + "value": { + "tenant_name": "", + "site_id": "", + "site_url": "", + "site_title": "", + "web_id": "", + "library_id": "", + "library_drive_id": "", + "library_name": "", + "library_title": "", + "library_absolute_url": "", + "folder_id": 0, + "folder_drive_id": "", + "folder_display_name": "", + "folder_absolute_url": "" + } + } + ] + } + }, + "Initialize_variable:_bSuccess": { + "runAfter": { + "Initialize_variable:_objResults": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "cf3e4e0b-dec0-4765-9a4d-9502369f34f9" + }, + "type": "InitializeVariable", + "inputs": { + "variables": [ + { + "name": "bSuccess", + "type": "boolean", + "value": "@false" + } + ] + } + }, + "Initialize_variable:_sErrorMessage": { + "runAfter": { + "Initialize_variable:_bSuccess": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "b993950a-531c-4231-b5e0-2cfcdc477d99" + }, + "type": "InitializeVariable", + "inputs": { + "variables": [ + { + "name": "sErrorMessage", + "type": "string" + } + ] + } + }, + "Scope:_retrieve_library_information_for_the_record": { + "actions": { + "Get_sharepoint_document_locations_for_current_record": { + "runAfter": {}, + "metadata": { + "operationMetadataId": "35688dd6-b1fa-4692-9fec-8d8840927254" + }, + "type": "OpenApiConnection", + "inputs": { + "host": { + "connectionName": "shared_commondataserviceforapps_1", + "operationId": "ListRecords", + "apiId": "/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps" + }, + "parameters": { + "entityName": "sharepointdocumentlocations", + "$select": "sitecollectionid, _regardingobjectid_value,relativeurl,name,sharepointdocumentlocationid", + "$filter": "_regardingobjectid_value eq '@{triggerBody()['text']}'", + "$top": 1 + }, + "authentication": "@parameters('$authentication')" + } + }, + "Scope:_Update_objResults,_set_'folder_display_name'": { + "actions": { + "Parse_JSON:_parse_first_value_from_response": { + "runAfter": {}, + "metadata": { + "operationMetadataId": "1dc9074f-5d18-4fef-98a3-0a7c2ddd95f2" + }, + "type": "ParseJson", + "inputs": { + "content": "@first(outputs('Get_sharepoint_document_locations_for_current_record')?['body/value'])", + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "_regardingobjectid_value": { + "type": "string" + }, + "sitecollectionid": { + "type": "string" + }, + "relativeurl": { + "type": "string" + }, + "sharepointdocumentlocationid": { + "type": "string" + } + } + } + } + }, + "Compose:_set_property_'folder_display_name'": { + "runAfter": { + "Parse_JSON:_parse_first_value_from_response": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "bbaf4a50-de08-4ab9-b2b5-b31131f8a24e" + }, + "type": "Compose", + "inputs": "@setProperty(variables('objResults'),'folder_display_name',body('Parse_JSON:_parse_first_value_from_response')?['relativeurl'])" + }, + "Set_objResults['folder_display_name']": { + "runAfter": { + "Compose:_set_property_'folder_display_name'": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "7bcfe2ea-3b9d-43e3-bd29-d15ad1247416" + }, + "type": "SetVariable", + "inputs": { + "name": "objResults", + "value": "@outputs('Compose:_set_property_''folder_display_name''')" + } + } + }, + "runAfter": { + "Get_sharepoint_document_locations_for_current_record": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "21ff116c-e21a-4391-8bde-a5a7fdf89203" + }, + "type": "Scope", + "description": "Set folder_display_name" + }, + "Condition": { + "actions": { + "Invoke_an_HTTP_request_against_Dataverse:_RetrieveAbsoluteAndSiteCollectionUrl": { + "runAfter": {}, + "metadata": { + "operationMetadataId": "c45e89c2-9b7c-47da-a9ce-b7bcafee321a" + }, + "type": "OpenApiConnection", + "inputs": { + "host": { + "connectionName": "shared_webcontents", + "operationId": "InvokeHttp", + "apiId": "/providers/Microsoft.PowerApps/apis/shared_webcontents" + }, + "parameters": { + "request/method": "GET", + "request/url": "/api/data/v9.2/sharepointdocumentlocations(@{body('Parse_JSON:_parse_first_value_from_response')?['sharepointdocumentlocationid']})/Microsoft.Dynamics.CRM.RetrieveAbsoluteAndSiteCollectionUrl()", + "request/headers": { + "Accept": "application/json", + "OData-MaxVersion": "4.0", + "OData-Version": "4.0" + } + }, + "authentication": "@parameters('$authentication')" + }, + "description": "Get url of the library used by the sharepoint integration for this record" + }, + "Scope:_Update_objResults,_set_siteUrl,_folderUrl,_libraryUrl,_hostname,_libTitle": { + "actions": { + "Parse_JSON:_RetrieveAbsoluteAndSiteCollectionUrlReply": { + "runAfter": {}, + "metadata": { + "operationMetadataId": "00ab74a1-bf48-4814-b5f6-1cff924f34a7" + }, + "type": "ParseJson", + "inputs": { + "content": "@body('Invoke_an_HTTP_request_against_Dataverse:_RetrieveAbsoluteAndSiteCollectionUrl')", + "schema": { + "type": "object", + "properties": { + "@@odata.context": { + "type": "string" + }, + "AbsoluteUrl": { + "type": "string" + }, + "SiteCollectionUrl": { + "type": "string" + } + } + } + } + }, + "Compose:_set_property_'folder_absolute_url'": { + "runAfter": { + "Set_variable_objResult['site_url']": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "47a9b71d-6f81-41b7-9da5-b8a8ea4e4091" + }, + "type": "Compose", + "inputs": "@setProperty(variables('objResults'),'folder_absolute_url',body('Parse_JSON:_RetrieveAbsoluteAndSiteCollectionUrlReply')?['AbsoluteUrl'])" + }, + "Set_variable_objResult['folder_absolute_url']": { + "runAfter": { + "Compose:_set_property_'folder_absolute_url'": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "4ded2ff3-4488-49d0-95d6-5cb47dec9919" + }, + "type": "SetVariable", + "inputs": { + "name": "objResults", + "value": "@outputs('Compose:_set_property_''folder_absolute_url''')" + } + }, + "Compose:_sSourceLibraryName": { + "runAfter": { + "Set_variable_objResults['library_absolute_url']": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "e026fb43-79b7-4d21-9149-e321dd2c3b36" + }, + "type": "Compose", + "inputs": "@replace(\r\n\treplace(\r\n\t\treplace(\r\n\t\t\tbody('Parse_JSON:_RetrieveAbsoluteAndSiteCollectionUrlReply')?['AbsoluteUrl'],\r\n\t\t\t\tbody('Parse_JSON:_RetrieveAbsoluteAndSiteCollectionUrlReply')?['SiteCollectionUrl'],''),\r\n\t\t\t\t\tbody('Parse_JSON:_parse_first_value_from_response')?['relativeurl'],'')\r\n\t\t\t\t,'/'\r\n\t\t,'')" + }, + "Compose:_set_property_'library_name'": { + "runAfter": { + "Compose:_sSourceLibraryName": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "7d671ad6-fa2c-4c5f-8bd1-58531f0ab746" + }, + "type": "Compose", + "inputs": "@setProperty(variables('objResults'),'library_name',outputs('Compose:_sSourceLibraryName'))" + }, + "Set_variable_objResult['library_name']": { + "runAfter": { + "Compose:_set_property_'library_name'": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "e7b3ca3f-c9ee-4bc5-a7ec-72d80aa11a7c" + }, + "type": "SetVariable", + "inputs": { + "name": "objResults", + "value": "@outputs('Compose:_set_property_''library_name''')" + } + }, + "Compose:_set_property_'host_name'": { + "runAfter": { + "Set_variable_objResult['library_name']": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "7b97f499-cb06-420f-834b-ceb13e5a9889" + }, + "type": "Compose", + "inputs": "@setProperty(variables('objResults'),'tenant_name',uriHost(body('Parse_JSON:_RetrieveAbsoluteAndSiteCollectionUrlReply')?['SiteCollectionUrl']))" + }, + "Set_variable_objResult['tenant_name']": { + "runAfter": { + "Compose:_set_property_'host_name'": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "2eee0c62-f70b-441e-9c75-c3c90d99f7f4" + }, + "type": "SetVariable", + "inputs": { + "name": "objResults", + "value": "@outputs('Compose:_set_property_''host_name''')" + } + }, + "Compose:_set_property_'library_url'": { + "runAfter": { + "Set_variable_objResult['folder_absolute_url']": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "b6ba3df3-568f-44dd-83b8-2d4fa1ea6c80" + }, + "type": "Compose", + "inputs": "@ setProperty(variables('objResults'),'library_absolute_url', \r\nreplace(\r\nbody('Parse_JSON:_RetrieveAbsoluteAndSiteCollectionUrlReply')?['AbsoluteUrl'],\r\nConcat('/',body('Parse_JSON:_parse_first_value_from_response')?['relativeurl']),\r\n'')\r\n)" + }, + "Set_variable_objResults['library_absolute_url']": { + "runAfter": { + "Compose:_set_property_'library_url'": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "d523cdf5-ded7-4000-8335-007e13b46780" + }, + "type": "SetVariable", + "inputs": { + "name": "objResults", + "value": "@outputs('Compose:_set_property_''library_url''')" + } + }, + "Compose:_set_property_'site_url'": { + "runAfter": { + "Parse_JSON:_RetrieveAbsoluteAndSiteCollectionUrlReply": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "007c9a91-1459-4d7b-9df6-830d63a93024" + }, + "type": "Compose", + "inputs": "@setProperty(variables('objResults'),'site_url',body('Parse_JSON:_RetrieveAbsoluteAndSiteCollectionUrlReply')?['SiteCollectionUrl'])" + }, + "Set_variable_objResult['site_url']": { + "runAfter": { + "Compose:_set_property_'site_url'": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "4add14ac-ce2f-40d6-b460-013f0a236883" + }, + "type": "SetVariable", + "inputs": { + "name": "objResults", + "value": "@outputs('Compose:_set_property_''site_url''')" + } + } + }, + "runAfter": { + "Invoke_an_HTTP_request_against_Dataverse:_RetrieveAbsoluteAndSiteCollectionUrl": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "c932006e-26a9-4f4b-8e45-c4533b474982" + }, + "type": "Scope", + "description": "Set 'folder_absolute_url', 'site_url', 'library_absolute_url', 'library_name', 'tenant_name'" + }, + "Send_an_HTTP_request_to_SharePoint:_get_Site_info": { + "runAfter": { + "Scope:_Update_objResults,_set_siteUrl,_folderUrl,_libraryUrl,_hostname,_libTitle": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "ff47974d-8237-43fb-ae08-7f972471307e" + }, + "type": "OpenApiConnection", + "inputs": { + "host": { + "connectionName": "shared_sharepointonline", + "operationId": "HttpRequest", + "apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline" + }, + "parameters": { + "dataset": "https://@{uriHost(body('Parse_JSON:_RetrieveAbsoluteAndSiteCollectionUrlReply')?['SiteCollectionUrl'])}", + "parameters/method": "GET", + "parameters/uri": "_api/v2.0/sites('@{uriHost(body('Parse_JSON:_RetrieveAbsoluteAndSiteCollectionUrlReply')?['SiteCollectionUrl'])}'):@{uriPath(body('Parse_JSON:_RetrieveAbsoluteAndSiteCollectionUrlReply')?['SiteCollectionUrl'])}?$select=id,title", + "parameters/headers": { + "Accept": "application/json" + } + }, + "authentication": "@parameters('$authentication')" + }, + "description": "Get list by InternalName (used in URL): filter by rootfolder" + }, + "Scope:_Update_objResults,_set_'site_title',_'site_id',_'web_id'": { + "actions": { + "Parse_JSON:_get_Site_Info_:_graphId,_title": { + "runAfter": {}, + "metadata": { + "operationMetadataId": "d27e37ce-294d-4556-a289-054d19592b13" + }, + "type": "ParseJson", + "inputs": { + "content": "@body('Send_an_HTTP_request_to_SharePoint:_get_Site_info')", + "schema": { + "type": "object", + "properties": { + "@@odata.context": { + "type": "string" + }, + "id": { + "type": "string" + }, + "title": { + "type": "string" + } + } + } + } + }, + "Compose:_set_property_'site_title'": { + "runAfter": { + "Parse_JSON:_get_Site_Info_:_graphId,_title": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "96bbc2d6-2dd0-4390-837b-89261caf51ee" + }, + "type": "Compose", + "inputs": "@setProperty(variables('objResults'),'site_title',body('Parse_JSON:_get_Site_Info_:_graphId,_title')?['title'])" + }, + "Set_variable:_objResults['site_title']": { + "runAfter": { + "Compose:_set_property_'site_title'": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "c20d228f-305e-4392-a966-1306985dc764" + }, + "type": "SetVariable", + "inputs": { + "name": "objResults", + "value": "@outputs('Compose:_set_property_''site_title''')" + } + }, + "Compose:_split_graphId": { + "runAfter": { + "Set_variable:_objResults['site_title']": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "6285fda3-477c-4bee-be82-75896a46fbf8" + }, + "type": "Compose", + "inputs": "@split(body('Parse_JSON:_get_Site_Info_:_graphId,_title')?['id'],',')" + }, + "Compose:_set_property_'web_id'": { + "runAfter": { + "Set_objResults['site_id']": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "e7f4a746-bab7-4ea6-a5cf-4d6322869b72" + }, + "type": "Compose", + "inputs": "@setProperty(variables('objResults'),'web_id',outputs('Compose:_split_graphId')?[2])" + }, + "Set_variable:_objResults['web_id']": { + "runAfter": { + "Compose:_set_property_'web_id'": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "c152caba-c696-4284-8a4a-addbe6d373d5" + }, + "type": "SetVariable", + "inputs": { + "name": "objResults", + "value": "@outputs('Compose:_set_property_''web_id''')" + } + }, + "Set_objResults['site_id']": { + "runAfter": { + "Compose:_set_property_'site_id'": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "88e4645f-1b5a-4d8a-a2d2-02bca3e817a2" + }, + "type": "SetVariable", + "inputs": { + "name": "objResults", + "value": "@outputs('Compose:_set_property_''site_id''')" + } + }, + "Compose:_set_property_'site_id'": { + "runAfter": { + "Compose:_split_graphId": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "e0f588f7-9d7a-4c4f-bf75-bf4e194c5952" + }, + "type": "Compose", + "inputs": "@setProperty(variables('objResults'),'site_id',outputs('Compose:_split_graphId')?[1])" + } + }, + "runAfter": { + "Send_an_HTTP_request_to_SharePoint:_get_Site_info": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "9d4a57a1-70ca-42e7-8d8c-78715eef5988" + }, + "type": "Scope" + }, + "Send_an_HTTP_request_to_SharePoint:_get_List_info": { + "runAfter": { + "Scope": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "ff47974d-8237-43fb-ae08-7f972471307e" + }, + "type": "OpenApiConnection", + "inputs": { + "host": { + "connectionName": "shared_sharepointonline", + "operationId": "HttpRequest", + "apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline" + }, + "parameters": { + "dataset": "@body('Parse_JSON:_RetrieveAbsoluteAndSiteCollectionUrlReply')?['SiteCollectionUrl']", + "parameters/method": "GET", + "parameters/uri": "/_api/lists?$expand=RootFolder&$filter=(RootFolder/Name eq '@{outputs('Compose:_sSourceLibraryName')}')&$select=Id,Title,ParentWebUrl", + "parameters/headers": { + "Accept": "application/json;odata=nometadata", + "Content-Type": "application/json;odata=verbose;charset=utf-8" + } + }, + "authentication": "@parameters('$authentication')" + }, + "description": "Get list by InternalName (used in URL): filter by rootfolder" + }, + "Scope:_Update_objResults,_set_'library_id',_'library_title'": { + "actions": { + "Parse_JSON:_retrieve_Title_and_Id": { + "runAfter": {}, + "metadata": { + "operationMetadataId": "1a39c639-56a2-4145-ad72-798ad8c0d331" + }, + "type": "ParseJson", + "inputs": { + "content": "@body('Send_an_HTTP_request_to_SharePoint:_get_List_info')", + "schema": { + "type": "object", + "properties": { + "value": { + "type": "array", + "items": { + "type": "object", + "properties": { + "RootFolder": { + "type": "object", + "properties": { + "Exists": { + "type": "boolean" + }, + "ExistsAllowThrowForPolicyFailures": { + "type": "boolean" + }, + "ExistsWithException": { + "type": "boolean" + }, + "IsWOPIEnabled": { + "type": "boolean" + }, + "ItemCount": { + "type": "integer" + }, + "Name": { + "type": "string" + }, + "ProgID": {}, + "ServerRelativeUrl": { + "type": "string" + }, + "TimeCreated": { + "type": "string" + }, + "TimeLastModified": { + "type": "string" + }, + "UniqueId": { + "type": "string" + }, + "WelcomePage": { + "type": "string" + } + } + }, + "Id": { + "type": "string" + }, + "ParentWebUrl": { + "type": "string" + }, + "Title": { + "type": "string" + } + }, + "required": [ + "RootFolder", + "Id", + "ParentWebUrl", + "Title" + ] + } + } + } + } + } + }, + "Compose:_set_property_'library_id'": { + "runAfter": { + "Parse_JSON:_retrieve_Title_and_Id": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "450a0229-40ed-4c46-ba1f-b25a0e13562e" + }, + "type": "Compose", + "inputs": "@setProperty(variables('objResults'),'library_id',first(body('Parse_JSON:_retrieve_Title_and_Id')?['value'])?['Id'])" + }, + "Compose:_set_property_'library_title'": { + "runAfter": { + "Set_variable_objResults['library_id']": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "44f4247c-ca4f-4def-b8bc-1f6fdf68e351" + }, + "type": "Compose", + "inputs": "@setProperty(variables('objResults'),'library_title',first(body('Parse_JSON:_retrieve_Title_and_Id')?['value'])?['Title'])" + }, + "Set_variable_objResults['library_id']": { + "runAfter": { + "Compose:_set_property_'library_id'": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "476e8f52-25e8-44e0-a9af-5f100d69b2ff" + }, + "type": "SetVariable", + "inputs": { + "name": "objResults", + "value": "@outputs('Compose:_set_property_''library_id''')" + } + }, + "Set_variable_objResults['library_Title']": { + "runAfter": { + "Compose:_set_property_'library_title'": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "3475089f-003a-4b48-9d0a-6bd7de96d38f" + }, + "type": "SetVariable", + "inputs": { + "name": "objResults", + "value": "@outputs('Compose:_set_property_''library_title''')" + } + } + }, + "runAfter": { + "Send_an_HTTP_request_to_SharePoint:_get_List_info": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "219e4005-d81f-4911-9a06-388f9261799a" + }, + "type": "Scope" + }, + "Send_an_HTTP_request_to_SharePoint:_get_folder_by_relative_Url": { + "runAfter": { + "Scope:_Update_objResults,_set_'library_id',_'library_title'": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "ff47974d-8237-43fb-ae08-7f972471307e" + }, + "type": "OpenApiConnection", + "inputs": { + "host": { + "connectionName": "shared_sharepointonline", + "operationId": "HttpRequest", + "apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline" + }, + "parameters": { + "dataset": "@body('Parse_JSON:_RetrieveAbsoluteAndSiteCollectionUrlReply')?['SiteCollectionUrl']", + "parameters/method": "GET", + "parameters/uri": "/_api/web/GetFolderByServerRelativeUrl('@{substring(replace(body('Parse_JSON:_RetrieveAbsoluteAndSiteCollectionUrlReply')?['AbsoluteUrl'],body('Parse_JSON:_RetrieveAbsoluteAndSiteCollectionUrlReply')?['SiteCollectionUrl'],''),1)}')/ListItemAllFields", + "parameters/headers": { + "Accept": "application/json", + "Content-Type": "application/json;odata=verbose;charset=utf-8" + } + }, + "authentication": "@parameters('$authentication')" + }, + "description": "Get list by InternalName (used in URL): filter by rootfolder" + }, + "Scope:_Update_objResults,_set_'folder_Id'": { + "actions": { + "Parse_JSON:_get_folderId_and_link": { + "runAfter": {}, + "metadata": { + "operationMetadataId": "6b9b65e8-9c62-4c52-a5d9-af92144333a8" + }, + "type": "ParseJson", + "inputs": { + "content": "@body('Send_an_HTTP_request_to_SharePoint:_get_folder_by_relative_Url')", + "schema": { + "type": "object", + "properties": { + "odata.editLink": { + "type": "string" + }, + "FileSystemObjectType": { + "type": "integer" + }, + "Id": { + "type": "integer" + }, + "ID": { + "type": "integer" + }, + "GUID": { + "type": "string" + } + } + } + } + }, + "Compose:_set_Property_'folder_Id'": { + "runAfter": { + "Parse_JSON:_get_folderId_and_link": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "b4f939d3-2373-431a-814c-1988a3d0fe64" + }, + "type": "Compose", + "inputs": "@setProperty(variables('objResults'),'folder_id',body('Parse_JSON:_get_folderId_and_link')?['Id'])\r\n" + }, + "Set_variable:_objResults['folder_id']": { + "runAfter": { + "Compose:_set_Property_'folder_Id'": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "6912819a-c1ac-42ff-8af5-67dc0e36292f" + }, + "type": "SetVariable", + "inputs": { + "name": "objResults", + "value": "@outputs('Compose:_set_Property_''folder_Id''')" + } + } + }, + "runAfter": { + "Send_an_HTTP_request_to_SharePoint:_get_folder_by_relative_Url": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "6c004c1e-f7cb-4f18-acdb-f0e66131fcb4" + }, + "type": "Scope" + }, + "Send_an_HTTP_request_to_SharePoint:_get_library_driveId": { + "runAfter": { + "Scope:_Update_objResults,_set_'site_title',_'site_id',_'web_id'": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "ff47974d-8237-43fb-ae08-7f972471307e" + }, + "type": "OpenApiConnection", + "inputs": { + "host": { + "connectionName": "shared_sharepointonline", + "operationId": "HttpRequest", + "apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline" + }, + "parameters": { + "dataset": "@body('Parse_JSON:_RetrieveAbsoluteAndSiteCollectionUrlReply')?['SiteCollectionUrl']", + "parameters/method": "GET", + "parameters/uri": "_api/v2.0/sites('@{body('Parse_JSON:_get_Site_Info_:_graphId,_title')?['id']}')/drives?$select=id,webUrl", + "parameters/headers": { + "Accept": "application/json", + "Content-Type": "application/json;odata=verbose;charset=utf-8" + } + }, + "authentication": "@parameters('$authentication')" + }, + "description": "Get list by InternalName (used in URL): filter by rootfolder" + }, + "Scope:_update_objResults:_set_'library_drive_id'": { + "actions": { + "Parse_JSON:_get_driveId_and_webUrl": { + "runAfter": {}, + "metadata": { + "operationMetadataId": "b89032fa-8ca5-4eee-b7b8-3a11e4b8c52b" + }, + "type": "ParseJson", + "inputs": { + "content": "@body('Send_an_HTTP_request_to_SharePoint:_get_library_driveId')", + "schema": { + "type": "object", + "properties": { + "@@odata.context": { + "type": "string" + }, + "value": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "webUrl": { + "type": "string" + } + }, + "required": [ + "id", + "webUrl" + ] + } + } + } + } + } + }, + "Filter_array:_get_record_for_the_library": { + "runAfter": { + "Parse_JSON:_get_driveId_and_webUrl": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "148c7030-403c-4453-a2ad-394d6f2196c5" + }, + "type": "Query", + "inputs": { + "from": "@body('Parse_JSON:_get_driveId_and_webUrl')?['value']", + "where": "@equals(item()?['webUrl'], replace(body('Parse_JSON:_RetrieveAbsoluteAndSiteCollectionUrlReply')?['AbsoluteUrl'], Concat('/', body('Parse_JSON:_parse_first_value_from_response')?['relativeurl']), ''))" + } + }, + "Compose:_set_property_'library_drive_id'": { + "runAfter": { + "Filter_array:_get_record_for_the_library": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "de6d8003-66ab-4da2-96d1-1f22fa10cf30" + }, + "type": "Compose", + "inputs": "@ setProperty(variables('objResults'),'library_drive_id', first(body('Filter_array:_get_record_for_the_library'))?['id'])" + }, + "Set_variable:_objResults['library_drive_id']": { + "runAfter": { + "Compose:_set_property_'library_drive_id'": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "8e258912-c9c4-46ec-aea4-094869f1cb08" + }, + "type": "SetVariable", + "inputs": { + "name": "objResults", + "value": "@outputs('Compose:_set_property_''library_drive_id''')" + } + } + }, + "runAfter": { + "Send_an_HTTP_request_to_SharePoint:_get_library_driveId": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "c4a238d9-4931-4120-be79-1b86ec9dadb9" + }, + "type": "Scope" + }, + "Send_an_HTTP_request_to_SharePoint:_get_folder_driveId": { + "runAfter": { + "Scope:_update_objResults:_set_'library_drive_id'": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "ff47974d-8237-43fb-ae08-7f972471307e" + }, + "type": "OpenApiConnection", + "inputs": { + "host": { + "connectionName": "shared_sharepointonline", + "operationId": "HttpRequest", + "apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline" + }, + "parameters": { + "dataset": "@body('Parse_JSON:_RetrieveAbsoluteAndSiteCollectionUrlReply')?['SiteCollectionUrl']", + "parameters/method": "GET", + "parameters/uri": "_api/v2.0/drives('@{first(body('Filter_array:_get_record_for_the_library'))?['id']}')/root:/@{body('Parse_JSON:_parse_first_value_from_response')?['relativeurl']}?$select=id", + "parameters/headers": { + "Accept": "application/json", + "Content-Type": "application/json;odata=verbose;charset=utf-8" + } + }, + "authentication": "@parameters('$authentication')" + }, + "description": "Get list by InternalName (used in URL): filter by rootfolder" + }, + "Scope": { + "actions": { + "Parse_JSON:_get_folder_drive_id": { + "runAfter": {}, + "metadata": { + "operationMetadataId": "86cd4e85-ea66-4b44-80e8-7d5d6056376a" + }, + "type": "ParseJson", + "inputs": { + "content": "@body('Send_an_HTTP_request_to_SharePoint:_get_folder_driveId')", + "schema": { + "type": "object", + "properties": { + "@@odata.context": { + "type": "string" + }, + "@@odata.etag": { + "type": "string" + }, + "id": { + "type": "string" + } + } + } + } + }, + "Compose:_set_property_'folder_drive_id'": { + "runAfter": { + "Parse_JSON:_get_folder_drive_id": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "761c4062-1638-4c02-acb7-2a16cd8c6baa" + }, + "type": "Compose", + "inputs": "@ setProperty(variables('objResults'),'folder_drive_id', body('Parse_JSON:_get_folder_drive_id')?['id'])" + }, + "Set_variable:_objResults['folder_drive_id']": { + "runAfter": { + "Compose:_set_property_'folder_drive_id'": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "bb8361e7-6f82-4b3b-99c7-65808e76a93b" + }, + "type": "SetVariable", + "inputs": { + "name": "objResults", + "value": "@outputs('Compose:_set_property_''folder_drive_id''')" + } + } + }, + "runAfter": { + "Send_an_HTTP_request_to_SharePoint:_get_folder_driveId": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "6c004c1e-f7cb-4f18-acdb-f0e66131fcb4" + }, + "type": "Scope" + } + }, + "runAfter": { + "Scope:_Update_objResults,_set_'folder_display_name'": [ + "Succeeded" + ] + }, + "expression": { + "greater": [ + "@length(outputs('Get_sharepoint_document_locations_for_current_record')?['body/value'])", + 0 + ] + }, + "metadata": { + "operationMetadataId": "62f712f5-62d7-419b-81b7-ee114b97b5df" + }, + "type": "If" + }, + "Parse_JSON:_objResults": { + "runAfter": { + "Condition": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "cdf094db-3124-4e14-b335-57ce790228a6" + }, + "type": "ParseJson", + "inputs": { + "content": "@variables('objResults')", + "schema": { + "type": "object", + "properties": { + "tenant_name": { + "type": "string" + }, + "site_id": { + "type": "string" + }, + "site_url": { + "type": "string" + }, + "site_title": { + "type": "string" + }, + "web_id": { + "type": "string" + }, + "library_id": { + "type": "string" + }, + "library_drive_id": { + "type": "string" + }, + "library_name": { + "type": "string" + }, + "library_title": { + "type": "string" + }, + "library_absolute_url": { + "type": "string" + }, + "folder_id": { + "type": "integer" + }, + "folder_drive_id": { + "type": "string" + }, + "folder_display_name": { + "type": "string" + }, + "folder_absolute_url": { + "type": "string" + } + } + } + } + }, + "Set_variable:_bSuccess_=_true": { + "runAfter": { + "Parse_JSON:_objResults": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "a01fb01c-6a54-4cfe-9b02-9badf3657991" + }, + "type": "SetVariable", + "inputs": { + "name": "bSuccess", + "value": "@true" + } + } + }, + "runAfter": { + "Initialize_variable:_sErrorMessage": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "540de42a-4366-445f-8f42-bd65044874a5" + }, + "type": "Scope" + }, + "Scope:_Error_Handling": { + "actions": { + "Filter_array:_get_Errors": { + "runAfter": {}, + "metadata": { + "operationMetadataId": "f9ed3e5d-bc09-45a2-ac2c-5f24789521fc" + }, + "type": "Query", + "inputs": { + "from": "@result('Scope:_retrieve_library_information_for_the_record')", + "where": "@equals(item()?['Status'], 'Failed')" + } + }, + "Select:_get_actions_and_errors": { + "runAfter": { + "Filter_array:_get_Errors": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "4f6269cb-bfed-4a4a-abc6-20d685df3312" + }, + "type": "Select", + "inputs": { + "from": "@body('Filter_array:_get_Errors')", + "select": { + "Error": "@{item()?['name']}: \" @{item()?['outputs']?['body']?['message']}\"" + } + } + }, + "Set_variable:_sError_Message": { + "runAfter": { + "Select:_get_actions_and_errors": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "6d62052b-7e3c-4d58-9df9-6ebd5e4cdb61" + }, + "type": "SetVariable", + "inputs": { + "name": "sErrorMessage", + "value": "@{join(body('Select:_get_actions_and_errors'), ',')}" + } + } + }, + "runAfter": { + "Scope:_retrieve_library_information_for_the_record": [ + "Failed", + "TimedOut" + ] + }, + "metadata": { + "operationMetadataId": "afdee7da-1027-400b-b760-86147d8a3d56" + }, + "type": "Scope" + } + } + }, + "templateName": "" + }, + "schemaVersion": "1.0.0.0" +} \ No newline at end of file diff --git a/samples/utility_flow_get_sharepoint_location_for_dataverse_record/sourcecode/GetDataverserecordSPO/src/Workflows/GetSharePointlocationforrecord-EFF48012-4F77-EF11-AC20-002248C9A7CB.json.data.xml b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/sourcecode/GetDataverserecordSPO/src/Workflows/GetSharePointlocationforrecord-EFF48012-4F77-EF11-AC20-002248C9A7CB.json.data.xml new file mode 100644 index 00000000..db1a8a4a --- /dev/null +++ b/samples/utility_flow_get_sharepoint_location_for_dataverse_record/sourcecode/GetDataverserecordSPO/src/Workflows/GetSharePointlocationforrecord-EFF48012-4F77-EF11-AC20-002248C9A7CB.json.data.xml @@ -0,0 +1,29 @@ + + + /Workflows/GetSharePointlocationforrecord-EFF48012-4F77-EF11-AC20-002248C9A7CB.json + 1 + 0 + 5 + 0 + 4 + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 1 + 1 + 1.0.2.5 + 1 + 1 + [{"id":"idapps_ExternalCloudAssessment","type":"UnifiedApp","metadata":{"displayName":"External Cloud Assessment"}}] + none + + + + + + + \ No newline at end of file