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 Apps / Expected Rrecord, Foun...
Power Apps
Answered

Expected Rrecord, Found Type Table.

(0) ShareShare
ReportReport
Posted on by

Hello,

 

This thread is resolve and junction documentation is missing on the web, community, youtube etc... so Enjoy reading for many to many custom relationship

 

I have 3 table, Idea --> 1:N --> Junction table <-- N:1 <-- Product

 

I have the following function : 

 

ForAll(
cbIdea.SelectedItems,
Collect(
colideatopatchproduct,
{
Id: ThisRecord.ID,
Value: ThisRecord.Subject
}
)
);
ForAll(
cbproduct.SelectedItems,
Collect(
colProducttopatch,
{
Id: ThisRecord.ProductID,
Value: ThisRecord.Name

}
)
);

Patch(
Junction_Table_Idea_Products,
Defaults(Junction_Table_Idea_Products),
{
Name: "Test",
Product_L: colProducttopatch.Value
}
)

 

I'm getting an error that it is expecting a record and found a table, I tried adding .value or .Id still doesn't make a change...

Categories:
I have the same question (0)
  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    Hey @Anonymous 

    which part has the error:

     

    This last part jumps out to me so i am assuming it is here:

     

     

    Patch(
    Junction_Table_Idea_Products,
    Defaults(Junction_Table_Idea_Products),
    {
    Name: "Test",
    Product_L: colProducttopatch.Value
    }
    )
    
     

     

     

    How many records are you getting in colProducttopatch is it more than one if so i am expecting that part to look more like:

     

     

    ForAll(colProducttopatch As prodbeingpatched,
    Patch(
    Junction_Table_Idea_Products,
    Defaults(Junction_Table_Idea_Products),
    {
    Name: "Test",
    Product_L: prodbeingpatched.Value
    }
    )
    )
    
     

     

     

    if your only expecting the one i was expecting to see something more like:

     

    Patch(
    Junction_Table_Idea_Products,
    Defaults(Junction_Table_Idea_Products),
    {
    Name: "Test",
    Product_L: First(colProducttopatch).Value
    }
    )
    
     ​

    let me know how my suggestions go and if it doesn't work or i have misunderstood please do let me know 🙂

  • Community Power Platform Member Profile Picture
    on at

    @AJ_Z ,

     

    I have multiple record, I added your code but still the same error.

     

    ForAll(
    colProducttopatch As prodbeingpatched,
    Patch(
    Junction_Table_Idea_Products,
    {JunctionID: Blank()},
    {
    Name: "test",
    Product_L: prodbeingpatched.Value
    }
    )
    )

     

    rhamza_0-1641687067257.png

     

     

     

     

  • Community Power Platform Member Profile Picture
    on at

    Here is the structure

     

    Table Product1:NJunction TableN:1Table Idea 
          
    A   Idea1 
    B   Idea2 
    C   Idea3 

     

    So when I enter my idea so let's say it is Idea number 3 and I select 3 product.

     

    I want the junction table to be

     

    Idea 3 - Product A

    Idea 3 - Product B

    Idea 3 - Product C

     

    If I choose Idea 1 and select 2 product. 

     

    I want 

     

    Idea 1 A

    Idea 1 B

     

    with a table result :

     

    AIdea1
    BIdea1
    AIdea3
    BIdea3
    CIdea3

     

    ** Obviously the choose of product is selected combo box and the idea will be a "text" called Subject of the Idea.

  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    Okay thanks for this explanation 🙂 what type of column is Product_L is it Choice?

  • Community Power Platform Member Profile Picture
    on at

    @AJ_Z 

     

    In junction table, it is the lookup to Product

     

    rhamza_0-1641689074537.png

     

     

    rhamza_1-1641689146523.png

     

  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    That is the problem. In my solution I incorrectly assumed it was text so only part of my solution works. I am going to retype up the same solution with a change. Before I do so, am i right in saying that all products have a unique name? 

    Also, what is the items property for: cbproduct

    Does the Value column in the collection colProducttopatch correspond to the name of the Product in the sharepoint field? If that column corresponds to a unique field there we can use that to patch a lookup. I can show you what I mean once you are able to confirm the questions I have 🙂 .

     

  • Community Power Platform Member Profile Picture
    on at

    @AJ_Z 

     

    All Product should have a unique name yes. As of right now it is only text with an ID. ( But yes we are not suppose to have 2 product with the same name ) 

     

    cbproduct : 

    rhamza_0-1641689873823.png

     

    I'm not using sharepoint but CDS ( Dataverse ) :

     

    rhamza_3-1641689994234.png

     

     

     

     

     

  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    Okay this might not be the final solution as i am making some assumptions but I am just updating the solution options as I gather more information:

    Option One

     

     

    ForAll(
    cbIdea.SelectedItems,
    Collect(
    colideatopatchproduct,
    {
    Id: ThisRecord.ID,
    Value: ThisRecord.Subject
    }
    )
    );
    ForAll(
    cbproduct.SelectedItems As cbprodselected,
    Collect(
    colProducttopatch,
    {
    Id: cbprodselected.ProductID,
    Value: cbprodselected.Name
    
    }
    );
    Patch(
    Junction_Table_Idea_Products,
    Defaults(Junction_Table_Idea_Products),
    {
    Name: "Test",
    Product_L: cbprodselected
    }
    )
    
    );
    
    
     ​

     

     

    Option 2

     

    ForAll(
    cbIdea.SelectedItems,
    Collect(
    colideatopatchproduct,
    {
    Id: ThisRecord.ID,
    Value: ThisRecord.Subject
    }
    )
    );
    ForAll(
    cbproduct.SelectedItems As cbprodselected,
    Collect(
    colProducttopatch,
    {
    Id: cbprodselected.ProductID,
    Value: cbprodselected.Name
    
    }
    );
    Patch(
    Junction_Table_Idea_Products,
    Defaults(Junction_Table_Idea_Products),
    {
    Name: "Test",
    Product_L: LookUp(Products,ProductID= cbprodselected.ProductID)
    }
    )
    
    );
    
    
     

     

     

    If neither of these work it is likely either due to the names of the columns or the fact that I made an assumption that ProductID is the GUID for a record in the Products table which has been selected.

     

    Also I am assuming that the reason we ForAll through colProducttopatch is just to patch the selecteditems that we have collected for some other purpose but if it is to patch from other sources in the app aswell it would need to look more like:

     

    Option 3

     

    ForAll(
    cbIdea.SelectedItems,
    Collect(
    colideatopatchproduct,
    {
    Id: ThisRecord.ID,
    Value: ThisRecord.Subject
    }
    )
    );
    ForAll(
    cbproduct.SelectedItems As cbprodselected,
    Collect(
    colProducttopatch,
    {
    Id: cbprodselected.ProductID,
    Value: cbprodselected.Name
    
    }
    )
    );
    ForAll(
    colProducttopatch As prodstopatch
    Patch(
    Junction_Table_Idea_Products,
    Defaults(Junction_Table_Idea_Products),
    {
    Name: "Test",
    Product_L: LookUp(Products,ProductID= prodstopatch.Id)
    }
    )
    );
    
    
     

     

     

     

    if none of these scenarios are your one I would like a screenshot of the column names from the products table and from the juction table. I have ordered the options in most likely to be your scenario

  • Community Power Platform Member Profile Picture
    on at

    So far the option 1 seems to be right on. I'll run some test around it.

  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    Okay please run some tests and come back to me with any issues but so far the solution is:

     

    ForAll(
    cbIdea.SelectedItems,
    Collect(
    colideatopatchproduct,
    {
    Id: ThisRecord.ID,
    Value: ThisRecord.Subject
    }
    )
    );
    ForAll(
    cbproduct.SelectedItems As cbprodselected,
    Collect(
    colProducttopatch,
    {
    Id: cbprodselected.ProductID,
    Value: cbprodselected.Name
    
    }
    );
    Patch(
    Junction_Table_Idea_Products,
    Defaults(Junction_Table_Idea_Products),
    {
    Name: "Test",
    Product_L: cbprodselected
    }
    )
    
    );
    
    
     ​

    In your testing i want you to see if you already have many rows in the junction table relating to the same row in the product table. If you do test  cbprodselected to see if there is anything weird and run this forall patch.

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 Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard