Skip to main content

Notifications

Power Automate - Building Flows
Suggested answer

Power Automate Flow to Create/Update SharePoint Items Using User ID

Like (1) ShareShare
ReportReport
Posted on 3 Oct 2024 19:49:20 by 6

I’m working on a Power Automate flow that creates or updates an item in a SharePoint list from a Microsoft Form submission. I’m using the “Get user profile” action to pull the User ID. My goal is to allow individuals to update their original submission using their User ID as the unique key. How can this be fixed or what can I use as a unique key that I can reference when deciding if the form should create or update a row on the SharePoint list?

Here’s what I’ve done so far:

Trigger: When a new response is submitted (Microsoft Forms).
Action: Get response details (Microsoft Forms).
Action: Get user profile (Office 365 Users) to retrieve the User 'Id'.
Action: Initialize a variable to store the User ID. (Type: String; Value: "Id")
ActionGet items from SharePoint where the User ID matches the one from the form submission. Filter query: UserID eq variables('UserID') - keeps saying the expression is invalid and when testing says it is a bad request. It also displays the error message: ‘InvalidVariableOperation’ and message ‘The inputs of workflow run action ‘Get_items’ of type ‘OpenApiConnection’ are not valid. The variable ‘UserID’ must be initialized before it can be used inside action ‘Get_items’.’
Condition: Check if any items are returned by the “Get items” action. If true: Update the existing item. If false: Create a new item.
 
Any advice on how to resolve this issue or suggestions for a different approach to use a unique key for updating or creating items would be greatly appreciated!
  • NR-03101935-0 Profile Picture
    NR-03101935-0 6 on 07 Oct 2024 at 14:06:26
    Power Automate Flow to Create/Update SharePoint Items Using User ID
    Thank you all and I had another question. What should the condition expression be here?
  • Suggested answer
    Peter Rafai Profile Picture
    Peter Rafai 9 on 06 Oct 2024 at 15:55:33
    Power Automate Flow to Create/Update SharePoint Items Using User ID

    To resolve the issue in your Power Automate flow and ensure that the correct item is updated or created in the SharePoint list based on the form submission, there are a few steps you can take. 

    Steps to Resolve:

    1. In the Initialize variable action, confirm that you are correctly assigning the User ID from the Get user profile action.

    2. The value of the variable should be something like outputs('Get_user_profile')?

  • Expiscornovus Profile Picture
    Expiscornovus 31,017 on 06 Oct 2024 at 12:52:49
    Power Automate Flow to Create/Update SharePoint Items Using User ID
    Thanks for sharing your solution.
     
    You are correct, you need to use the internal name of the field. So, if it has been changed/renamed that would be the Title.
  • NR-03101935-0 Profile Picture
    NR-03101935-0 on 04 Oct 2024 at 18:47:08
    Power Automate Flow to Create/Update SharePoint Items Using User ID
    The filter query worked once I changed it to Title eq 'User ID'. The initialize variable action included the same three items, and even though the SharePoint column was titled ‘User ID’, it was originally renamed from the ‘Title’ column.
  • Expiscornovus Profile Picture
    Expiscornovus 31,017 on 04 Oct 2024 at 13:02:57
    Power Automate Flow to Create/Update SharePoint Items Using User ID
    What is the name of your variable? Maybe it is a small typo, did you use the correct variable name? Can you share a screenshot of your flow setup?
     
    Below is an example
     
    In this example the name of the variables is 'User ID', so the Filter Query would be:
    UserID eq '@{variables('User ID')}'
     
     
     
     

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #9 Get Recognized…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,238

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,290

Leaderboard
Loading started
Loading complete