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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch a collection to ...
Power Apps
Unanswered

Patch a collection to Sharepoint list with Lookup to another list

(0) ShareShare
ReportReport
Posted on by 47

I have 2 Sharepoint lists: "Client Supply Requests", and "Client Supplies."

"Client Supply Requests" has a lookup column to "Client Supplies" ID column.

 

The first list is meant to record each supply item a client requests on an individual row.

 

The intent here is to allow users to insert multiple rows into "Client Supply Requests" with a single button click. So, I have an app that has a few text input fields, and a dropdown that displays values from the "Client Supplies" list. There is an "Add" button that, when each time clicked, adds the currently selected items to a collection. The code is as follows:

 

Collect(
ClientSupplyCollection,
{
Col_Supply: dd_supply.Selected,

Col_SupplyID: dd_supply.Selected.Id,
Col_Requested: tb_ReqQty,
Col_Approved: tb_AppQty
}

)

I have a button called "Save" that has code:

 

ForAll(
ClientSupplyCollection,
Patch(
'Test Supply Request',
Defaults('Test Supply Request'),
{
Supply: Col_SupplyID,
'Requested Quantity': Col_Requested,
'Approved Quantity': Col_Approved
}
)
)

But when trying to patch the collection I get an error "The type of this argument 'Supply' does not match the expected type 'Record'. Found type 'Number'.

 

How do I get the type "Record" from my dropdown connected to the related list to patch the collection into my main list?

Categories:
  • cha_cha Profile Picture
    4,932 Moderator on at

    Hello @Rahul320 

     

    Try this code:

    ForAll(
     ClientSupplyCollection,
     Patch(
     'Test Supply Request',
     Defaults('Test Supply Request'),
     {
     Supply: Value(ThisRecord.Col_SupplyID),
     'Requested Quantity': ThisRecord.Col_Requested,
     'Approved Quantity': ThisRecord.Col_Approved
     }
     )
    )

     

    Let me know if there's any error after apply the change.

     


      ✔️
    Just in case my response helped you solve your problem, please mark/accept this as a SOLUTION.  This helps community members if they experience a similar issue in the future.

     

      🔗
    🕸bistek.space  🐦 @cha_bistek  📺 @BisTekSpace 
  • Rahul320 Profile Picture
    47 on at

    Unfortunately using 

    Supply: Value(ThisRecord.Col_SupplyID),

    Resulted in the same error.

     

    I should also add that I made a mistake in my original post - my first Sharepoint list is named "Test Client Request" which is why you see that in my patch statement.

     

    Any other ideas would be greatly appreciated!

  • Rahul320 Profile Picture
    47 on at

    Another mistake in my comment above - the first SP list is "Test Supply Request"

  • cha_cha Profile Picture
    4,932 Moderator on at

    try this again pls:

     

    ForAll(
     ClientSupplyCollection,
     Patch(
     'Test Supply Request',
     Defaults('Test Supply Request'),
     {
     Supply:{Value: ThisRecord.Col_SupplyID},
     'Requested Quantity': ThisRecord.Col_Requested,
     'Approved Quantity': ThisRecord.Col_Approved
     }
     )
    )

     

    by the way, what is the column type of Supply in your SharePoint?  

  • Rahul320 Profile Picture
    47 on at

    I now get: "Invalid argument type. Expecting a Record value, but of a different schema"

    Second error line says "Missing column. Your formula is missing a column 'Id' with a type of 'Number'.

     

    All errors go away, btw, if I remove the "Supply" item in my Patch and since the "Supply" column isn't required the patch works fine and adds multiple rows to the list as expected.

  • cha_cha Profile Picture
    4,932 Moderator on at

    Hello @Rahul320 

     

    Still need to know what type of column is Supply. but if you are happy with the outcome of your testing, still glad you got I sorted

     

    This would have been my next code suggestion.

     

    ForAll(
     ClientSupplyCollection,
     Patch(
     'Test Supply Request',
     Defaults('Test Supply Request'),
     {
     Supply:{Id: ThisRecord.Col_SupplyID},
     'Requested Quantity': ThisRecord.Col_Requested,
     'Approved Quantity': ThisRecord.Col_Approved
     }
     )
    )

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    x

  • Rahul320 Profile Picture
    47 on at

    I still need to populate the Supply column so more to be done. I tried your latest code suggestion but it gives me the same error. The Supply column is of type lookup:

     

    Rahul320_0-1671126501826.png

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 339 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 289

#3
Mohsin Ali Profile Picture

Mohsin Ali 228

Last 30 days Overall leaderboard