Power Automate: Dynamically retrieve SharePoint Online Document Library 'Drive ID'

Thought I'd add a fancy AI-generated blog header from Microsoft Designer while we're here !


Problem

  • Had a Power Automate Flow that would grab a document from a document library and PDF it.  
  • Needed to make the 'Document Library' field dynamic as the workflow was moving between DEV/TEST/PROD environments inside a Managed Solution 
  • Putting the Name of the document library in that field was not working.


How

What you need to input into that field, is what's called the 'Drive ID' of the document library.  Which is not immediately available without making a HTTP Call.  So do this to get the drive ID of the specific library you're after:



Code for each step

  • Filter Array FROM value: body('Send_an_HTTP_request_to_SharePoint_-_Get_Library_Metadata')['body']['value']
  • Filter Array Advanced Code: equals(item()?['name'], 'NAME OF DOCUMENT LIBRARY')
  • Document Library Field Code: first(body('Filter_array_-_Get_DOCX_DriveID'))?['id']


What do I get now?

Now you have a workflow that can be put into a MANAGED solution, so that regardless of which SharePoint site it is querying, as long as the Library has the same name, it will pick it up.


Comments

Popular posts from this blog

SharePoint - Field type [FieldName] is not installed properly. Go to the list settings page to delete this field.

Office 365 Groups - Quickly find the GUID of a O365 Group

Export Group Membership From Active Directory Using Power Query