web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Get File Identifier fr...
Power Automate
Unanswered

Get File Identifier from array variable

(0) ShareShare
ReportReport
Posted on by

Hi everyone

 

I have created a flow along the same lines as this which loops through a folder and all subfolders in a SharePoint library, building up an array of all the documents in them.  This works perfectly but now I want to copy the files that have been found to a different library.

 

However, I can't find a way of referencing the file identifier from the array variable:

 

gj84uw_0-1603382543572.png

I've tried using the Parse JSON action and this allows me to select the {Identifier} property but then I get an error saying that arrays can only be referenced by their index number and not a property.  Is there a way to achieve what I'm trying to do?

 

Thanks in advance for your help.

Categories:
I have the same question (0)
  • fchopo Profile Picture
    8,003 Moderator on at

    Hello @Anonymous 

    Could you share the JSON data you are trying to parse?

    Regards,

    Ferran

  • Community Power Platform Member Profile Picture
    on at

    Thanks for the reply @fchopo 

    The schema for the data is below.  I've got an array variable that is being appended to each time the flow finds a document in the folder structure.  Once that array has been created I then want to copy each file to another library using the Copy file action so I was hoping to just add the file identifier for each file dynamically.

    With the below, if I pass the array variable to the parse JSON action with the type set to object then I get an error saying that it was expecting an object but received an array.  Changing the type to array means the Parse JSON action completes successfully but the Copy file fails as where I'm using the Identifier property it fails saying Array elements can only be selected using an integer index.

    {

        "type": "object",
        "properties": {
            "@@odata.etag": {
                "type": "string"
            },
            "ItemInternalId": {
                "type": "string"
            },
            "ID": {
                "type": "integer"
            },
            "Modified": {
                "type": "string"
            },
            "Editor": {
                "type": "object",
                "properties": {
                    "@@odata.type": {
                        "type": "string"
                    },
                    "Claims": {
                        "type": "string"
                    },
                    "DisplayName": {
                        "type": "string"
                    },
                    "Email": {
                        "type": "string"
                    },
                    "Picture": {
                        "type": "string"
                    },
                    "Department": {
                        "type": "string"
                    },
                    "JobTitle": {
                        "type": "string"
                    }
                }
            },
            "Editor#Claims": {
                "type": "string"
            },
            "OData__dlc_DocId": {
                "type": "string"
            },
            "OData__dlc_DocIdUrl": {
                "type": "string"
            },
            "Certificate": {
                "type": "object",
                "properties": {
                    "@@odata.type": {
                        "type": "string"
                    },
                    "Id": {
                        "type": "integer"
                    },
                    "Value": {
                        "type": "string"
                    }
                }
            },
            "Certificate#Id": {
                "type": "integer"
            },
            "CertCopied": {
                "type": "boolean"
            },
            "SharedWithUsers": {
                "type": "array"
            },
            "SharedWithUsers@odata.type": {
                "type": "string"
            },
            "SharedWithUsers#Claims": {
                "type": "array"
            },
            "SharedWithUsers#Claims@odata.type": {
                "type": "string"
            },
            "Created": {
                "type": "string"
            },
            "Author": {
                "type": "object",
                "properties": {
                    "@@odata.type": {
                        "type": "string"
                    },
                    "Claims": {
                        "type": "string"
                    },
                    "DisplayName": {
                        "type": "string"
                    },
                    "Email": {},
                    "Picture": {},
                    "Department": {},
                    "JobTitle": {}
                }
            },
            "Author#Claims": {
                "type": "string"
            },
            "OData__DisplayName": {
                "type": "string"
            },
            "{Identifier}": {
                "type": "string"
            },
            "{IsFolder}": {
                "type": "boolean"
            },
            "{Thumbnail}": {
                "type": "object",
                "properties": {
                    "Large": {
                        "type": "string"
                    },
                    "Medium": {
                        "type": "string"
                    },
                    "Small": {
                        "type": "string"
                    }
                }
            },
            "{Link}": {
                "type": "string"
            },
            "{Name}": {
                "type": "string"
            },
            "{FilenameWithExtension}": {
                "type": "string"
            },
            "{Path}": {
                "type": "string"
            },
            "{FullPath}": {
                "type": "string"
            },
            "{IsCheckedOut}": {
                "type": "boolean"
            },
            "{VersionNumber}": {
                "type": "string"
            }
        }
    }
  • fchopo Profile Picture
    8,003 Moderator on at

    Hello @Anonymous 

    I'm trying to understand your problem, but need more context. Is this Parse JSON inside an apply to each action? As I understand, you have to copy the file for each element in the array, so an apply to each is needed.

    Could you share your flow?

    Regards,

    Ferran

  • Community Power Platform Member Profile Picture
    on at

    Hi @fchopo  sorry I don't think I've explained the flow very well so far.  The first part of it loops through a set of folders and subfolders and checks each item it finds for whether it's a folder or a file.  If it's a file it gets added to the varDocuments array variable:

    gj84uw_0-1603659849608.png

    Once the varDocuments array has been fully created I then have another for each step where I want each part of the array to be converted to JSON so I can then reference the {Identifier} property in order to copy each file:

    gj84uw_1-1603660085842.png

    I hope this makes more sense now but if you need any further information please don't hesitate to ask.

     

  • fchopo Profile Picture
    8,003 Moderator on at

    Hello @Anonymous 

    After the "Parse JSON" action, you should add an "apply for each" action, using a variable called "Body" of the "Parse JSON" action as input, and then, you will be able to select the {Identifier}.

    Have a look at this thread: https://powerusers.microsoft.com/t5/General-Power-Automate/Apply-to-each-error-when-parsing-JSON-quot-the-result-of-the/td-p/473904

     

    Hope it helps!

    Ferran

  • Paulie78 Profile Picture
    8,422 Moderator on at

    You could try using the expression item() instead of varDocuments in your parse JSON step. You are trying to use the Parse JSON against the whole array instead of just the current element within it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard