Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Issue patching gallery entries to secondary list

(0) ShareShare
ReportReport
Posted on 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
    Ramole on at
    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
    ShawnPelletier 85 on at
    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
    Ramole on at
    Re: Issue patching gallery entries to secondary list

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

  • ShawnPelletier Profile Picture
    ShawnPelletier 85 on at
    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
    Ramole on at
    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
    cmyoung07 125 on at
    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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

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

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,475

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,767

Leaderboard