Skip to main content
Community site session details

Community site session details

Session Id : Y+rvMuWQ350IY1RatCnFhL
Power Apps - Building Power Apps
Answered

Issue patching gallery entries to secondary list

Like (0) ShareShare
ReportReport
Posted on 17 Oct 2022 21:07:06 by 85

I have an app with the main form and a child list. I'm trying to save the collection records to the child list of the app. The foriegn key in the child list is named 'Parent' and is a lookup field to the main forms 'ID' field. The main form submits successfully, however the child records do not submit. The error is below:

 

"The type of this argument 'Parent' does not match the expected type 'Record'. Found type 'Number'"

 

My formula is below:

ForAll(OrderDetail,Patch('Construction Order Detail', Defaults('Construction Order Detail'), {Title: Manufacture, 'Item Description': Description, 'Item Master Number': Master, 'Quantity Requested': Quantity, 'Parent': 'CXM Form'.LastSubmit.ID})

 

Also, when I preview the form an empty blank record is present in the gallery, Im not sure why that's happening either.

 

  • Verified answer
    Ramole Profile Picture
    Super User 2024 Season 1 on 18 Nov 2022 at 04:07:22
    Re: Issue patching gallery entries to secondary list

    Hi@ShawnPelletier 
    You are missing 'Parent' 

     

     

    Set(
     gbllastSubmitted,
     Self.LastSubmit
    );
    Patch(
     'Construction Order Detail',
     Defaults('Construction Order Detail'),
     {
     Title: "Manufacturer Part #",
     'Item Description': "Test description",
     Requested: "10",
     'Parent': {
     Value: gbllastSubmitted.ID,
     Id: gbllastSubmitted.ID
     }
     }
    )

     

     

    You don't need to use again Form.LastSumit as we have already captured on the variable gbllastSubmitted.
    I will recommend you change the name parent to ParentLookup as the Parent normally used within PowerApps formulas. for example,

     

    Set(
     gbllastSubmitted,
     Self.LastSubmit
    );
    Patch(
     'Construction Order Detail',
     Defaults('Construction Order Detail'),
     {
     Title: "Manufacturer Part #",
     'Item Description': "Test description",
     Requested: "10",
     ParentLookup:
     {
     Value: gbllastSubmitted.ID,
     Id: gbllastSubmitted.ID
     }
     }
    )

     





  • ShawnPelletier Profile Picture
    85 on 17 Nov 2022 at 21:32:37
    Re: Issue patching gallery entries to secondary list

    OrderDetail (collection):

    ShawnPelletier_0-1668719412056.png

     Construction Order Detail (child list):

    ShawnPelletier_1-1668719571029.png

     

     I'm trying to patch:

    iDescription > Description

    iManufacturer > Title

    iMaster > Master

    iQtyOrdered > Requested

    ID of Master form > Parent

     

    Let me know if you need additional screenshots. Thank you.

  • Ramole Profile Picture
    Super User 2024 Season 1 on 17 Nov 2022 at 04:08:31
    Re: Issue patching gallery entries to secondary list

    @ShawnPelletier 
    Show me a screenshot of your backend SharePoint columns something not right. 

  • ShawnPelletier Profile Picture
    85 on 16 Nov 2022 at 18:44:10
    Re: Issue patching gallery entries to secondary list

    Here is what I'm running into now when trying to use the above:

    ShawnPelletier_0-1668624101537.png

    I renamed the child list fields to one word names to avoid issues and confusion with spacing, etc. This code is placed in 'OnSuccess' of the main form submission.

     

    Also, If I'm correct:

    Title: refers to child list column name

    : 'Manufacturer Part #' refers to the gallery column name assigned to 'Title'

     

    Where and how do the collection column names map into this? 

  • Ramole Profile Picture
    Super User 2024 Season 1 on 18 Oct 2022 at 04:11:49
    Re: Issue patching gallery entries to secondary list

    @ShawnPelletier 
    The reason you're getting the is error is Parent is a lookup so try this on form success 

     

     

    Set(
     gblLastSubmitted,
     Self.LastSubmit
    );
    
     Patch(
     ParentList,
     Defaults(ParentList),
     {
     Title: gblLastSubmitted.Title,
     'Parent': {
     Value: gblLastSubmitted.ID,
     Id: gblLastSubmitted.ID
     }
     }
     );

     


     Try this on your end

    Set(gblLastSubmitted,Self.LastSubmit);
    ForAll(OrderDetail,Patch('Construction Order Detail', Defaults('Construction Order Detail'), {Title: Manufacture, 
    'Item Description': Description, 
    'Item Master Number': Master,
    'Quantity Requested':Quantity,
    'Parent':{Value: gblLastSubmitted.ID,Id: gblLastSubmitted.ID}
    });
    
    
    



  • cmyoung07 Profile Picture
    125 on 18 Oct 2022 at 03:19:18
    Re: Issue patching gallery entries to secondary list

    I usually use set a variable to my patch results and then use that to reference the id.

    Set(varNewItem, Patch(<Main Patch Logic Here>));

     

    Then use the variable results in your other expression, so replace 'Parent': 'CXM Form'.LastSubmit.ID} with Parent: varNewItem.ID,

     

    Also check your quotes in your child patch expression, the field names should not be in quotes, so 'Parent' should be Parent.

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2

Loading complete