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 / Changing from Combo bo...
Power Apps
Answered

Changing from Combo box to gallery

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi folks,

 

I have the following code : 

 

ClearCollect(Mypatchedrecords,
Patch(
Ideas,
LookUp(Ideas, New_Idea_Gallery.Selected.IdeaID = IdeaID),
{Subject: Subject_input_1.Text,
Description: description_input_1.Text,
'Impact and Gain': Impact_Input_1.Text,
Budget: Value(Budget_input_1.Text),
'Time required': Value(Estimated_Hours_Input_1.Text),
'Is this related to a product ?': 'Product_relate_?_input_1'.Selected.Value,
'Status of the Idea': 'Status of the Idea'.Submited}
));
ForAll(
cbproduct_3.SelectedItems As cbprodselected,
Collect(
colProducttopatch,
{
Id: cbprodselected.ProductID,
Value: cbprodselected.Name
}
);
Patch(
Junction_Table_Idea_Products,
LookUp(Junction_Table_Idea_Products, New_Idea_Gallery.Selected.IdeaID = Idea_L.IdeaID),
{
Product_L: cbprodselected,
Idea_L : First(Mypatchedrecords)

}
));
Reset(Subject_input_1);
Reset(description_input_1);
Reset(Impact_Input_1);
Reset(Budget_input_1);
Reset(Estimated_Hours_Input_1);
Reset('Product_relate_?_input_1');
Reset(cbproduct_3);
Navigate(MainPage)

 

-------------

 

When I change cbproduct_3.selecteditems to gallery3_1.allitems.

 

I have an error stating : 

 

rhamza_0-1642085165577.png

 

Any idea ?

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    What is the Items property of gallery3_1 ?

     

    Your ForAll is backward.  You are trying to use a function that returns a table of records as a ForLoop developer function.  

     

    Patch is smart!  If you provide the primary key (ID), then it will automatically lookup and update the record.  If you do not provide an ID, then it will create a record.

     

    You can provide a table of records to patch and it will instantiate the action of patching on all of the records provided.

     

    I am not sure what your overall intention is with your formula, but you don't need all the steps you are doing in what you have.

    To patch a datasource from a Gallery, the only formula you need is the following:

    Patch(Junction_Table_Idea_Products,
     ForAll(gallery3_1.AllItems,
     {ID: ID,
     <columns to patch here>
     }
     )
    )

     

    I hope this is helpful for you. 

  • CU-18081211-6 Profile Picture
    9,272 Moderator on at

    @Anonymous ,

    The cbproduct_3.SelectedItems contains columns from items (data source) and gallery3_1.allitems in additions to the items columns contains columns with data about controls from the gallery.

    So, normally, in the second case (gallery3_1.allitems) you have a different schema. 

    Hope it helps !

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I tried that and it didn't work but again, my understanding is novice... 

     

    Gallery3_1 item is a collection called prodselected which has the following 

     

    rhamza_0-1642087657094.png

     

     

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    How are you putting records into prodselected?

    What is your datasource?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Here is the source of the prod collection

     

    ForAll(
    Gallery1_2.AllItems As galleryselected,
    Collect(
    prodselected,
    { ProductID: galleryselected.Product_L.ProductID,
    Name: galleryselected.Product_L.Name}
    )
    );
    ForAll(
    Products As galleryselected,
    Collect(
    prodavailable,
    { ProductID: galleryselected.ProductID,
    Name: galleryselected.Name}
    )
    )

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Again, the ForAll's are all backward.

    But still this appears to continue further back...what is the Items property of Gallery1_2 ?  I need to track this all back to your datasource.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Filter(
    Junction_Table_Idea_Products,
    Idea_L.IdeaID = New_Idea_Gallery.Selected.IdeaID
    )

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @RandyHayes 

     

    Gallery1_2 ( showing all product attach to the Idea )

     

    Filter(
    Junction_Table_Idea_Products,
    Idea_L.IdeaID = New_Idea_Gallery.Selected.IdeaID
    )

     

    There is an option to add a product or remove it via 2 other gallery

     

    rhamza_0-1642093016021.png

    rhamza_1-1642093068361.png

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    First, you don't need all the collections which are just duplicates of the data that you already have in your galleries.

    You can just reference those galleries.

     

    I would avoid changing column names as you go from gallery to gallery or anywhere else in the app.  Try to retain the original column names and you will save yourself a TON of work!

     

    If your use of collections is related to the ability to remove or add information in an In-Memory database table, then I would first consider the use of CheckBoxes instead, but if not feasible, then collections it is.

     

    What you do want to do is always pass your primary key to everyplace.  Never exclude it and your final work will be much easier.

    What is your primary key on the datasource?

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    The complicated part is because it is a N:N in form of a junction table.

     

    We have Idea 1:N to Junction Table and N:1 to Product

     

    The primary key of Idea table is : IdeaID

    The primary key of product table is : ProductID

    The primary key of the junction table is : Idea_Product_ID

     

    Whenever I need to interrogate the product or Idea table, I am missing one of the other ID which is found via a lookup and somehow I just can't get the schema correct and yes I was hoping you said there was easier ways... because it is a nightmare right now

     

     

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 356 Most Valuable Professional

#2
11manish Profile Picture

11manish 225 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 211

Last 30 days Overall leaderboard