6 thoughts on “Power Apps, Power Automate & SharePoint Media Service Metadata Magic – Part 2”

  1. Thank you very much for this post.

    I’m new working with Power Automate and since day I try to extract some metadata but without any success 🙁 Please can you help me (I’ll pay for it if needed)?

    I have the following output:
    “MediaServiceMetadata”: “{\”ctag\”:\”\\\”c:{a9c1b4df-3c8f-4cd8-aa76-68e4c26119a6},2\\\”\”,\”generationTime\”:\”2020-08-30T12:38:48.7697798Z\”,\”lastStreamUpdateTime\”:\”2020-08-30T12:38:48.7697798Z\”,\”modules\”:[{\”module\”:\”ThumbnailGeneration\”,\”version\”:1},{\”module\”:\”MetadataExtraction\”,\”version\”:1},{\”module\”:\”ObjectDetection\”,\”version\”:7},{\”module\”:\”ReverseGeocoding\”,\”version\”:1},{\”module\”:\”SystemTags\”,\”version\”:1},{\”module\”:\”TextExtractionData\”,\”version\”:1},{\”module\”:\”TextExtraction\”,\”version\”:2}],\”media\”:{\”author\”:[\”freshfocus\”],\”copyright\”:\”Sabine Ingold/statim design\”,\”keywords\”:[\”Sport\”,\”Fedcup\”,\”swiss tennis\”,\”tennis\”,\”2020\”],\”title\”:\”04.02.2020; Zürich; TENNIS – Tennis Fed Cup – Schweiz – Kanada; Pre-Draw-Pressekonferenz; \\r\\r(Sabine Ingold/statim design)\”},\”photo\”:{\”dateTaken\”:\”2020-02-04T13:37:42+00:00\”,\”width\”:1200,\”height\”:800},\”tags\”:[{\”name\”:\”person\”,\”localizedName\”:\”Person\”,\”confidence\”:0.996893048286438}]}”,

    At “Select – Fields to Return” I like to return for example the content of “Copyright” but I don’t know how I can do it. I tried so many things but nothing is working.

    Please can you give me an example (expression code?) how I can extract the content of copyright (\”copyright\”:\”Sabine Ingold/statim design\”)?

    Thank you very much
    Sabine

    1. Hi Sabine,

      Firstly apologies for the very late response – life happens ?.

      No doubt you’ve long moved on past this, however I nonetheless think your question is still relevant such that other people reading this blog post may face similar changes for their own use cases and understandably the expressions I used in the flows especially in the Fields to Return step are exceedingly difficult to follow, let alone clone and rework so as to add your own more specific fields to return to your apps.

      Accordingly, using the example you noted being Copyright as a desired new field to return, I spent some time looking into this insofar as what expression can be used to return only the Copyright value from the MediaServiceMetadata field for any given document. I believe I have now figured that out, albeit with limited testing.

      The expression I used for a new field mapping “Copypright” added to the “Fields to Return” action in the flow is as follows:
      if(empty(json( if( empty( item()?['listItem']?['fields']?['MediaServiceMetadata'] ), '{}', item()?['listItem']?['fields']?['MediaServiceMetadata'] ) )?['media']?['copyright']),'',json( if( empty( item()?['listItem']?['fields']?['MediaServiceMetadata'] ), '{}', item()?['listItem']?['fields']?['MediaServiceMetadata'] ) )?['media']?['copyright'])

      When adding or changing field mappings in the Fields to Return step in the flow, you equally need to ensure those changes are reflected in the final step in the flow Response action Response Body JSON Schema. For this change the schema definition for the new Copyright field being returned needs to be added to the existing Response Body JSON Schema.

      To do this copy the current schema into a text edit app, locate the definition for the OdataNextLink field, copy that field defintion schema such that it looks along the lines of:
      "OdataNextLink": {
      "type": "string"
      },
      "Copyright": {
      "type": "string"
      }

      Thereafter copy the entire updated schema definition back into the Response Body JSON Schema property on the Response action step in the flow. Save the flow. I recommend testing it with a previous (successful) flow run trigger. Hopefully all goes well!

      In your Power App(s) you’ll need to remove the flow from the app and add it again in order for Power Apps to recognise the change(s) to the Response schema definition.

      I have shared the updated Power Automate flow on GitHub that now includes returning a new field containing only the Copyright value (if present) as I’ve described here:
      SharePoint_MSM_DriveItems_v4

      Warm regards,
      Brian

Comments are closed.