cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rhamza
Helper V
Helper V

Changing from Combo box to gallery

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 ?

20 REPLIES 20

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

 

 

RandyHayes
Super User
Super User

@rhamza 

That is all just fine.  The point is to make sure you are pulling in the primary keys to your galleries.

When you are patching the junction table, you will be doing the patch formula I provided and supplying the Idea_Product_ID column to the statement.

Same for the others, you will need to provide the IdeaID for Idea table and ProductID for Product Table.  These ID should be brought in directly and used for the purpose of the patching.

This makes it all quite easy.

 

I am not familiar enough with your specific design to know which gallery is which and what you are trying to do in each.  But, for the most part, as I see it, you need two galleries - one for product and one for Ideas.  After that I am not sure exactly what you are doing. 

But, the beauty of the Patch statement (in regard to the junction table) is if you add new items, then the primary key (Idea_Product_ID) will be blank.  So when you issue the formula I provided, it will update any existing records and create new ones for the blank ones.

However...centering the above around collections is a challenge because the collections will not change when you do that.  You constantly need to maintain the collection.  If you just set the Items based on the actual table and filter based on the other gallery, then it will all be automatic.'

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Allright lets go step by step then.

 

I've removed all collection.

 

I only have 2 gallery. 

 

1: Showign all the product associated with the Idea ( galprodselected)

2: I need a gallery showing all the product except those already in gallery 1. ( galprodavailable )

 

I did it using a collection before but now I'm thinking...

 

1st gallery items : 

 

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

 

and the element in the glalery is : ThisItem.Product_L.Name

 

The second one I need something like... 

 

Filter(Products,Not(ProductID in Galprodselected.AllItems)) but it ain'T working.

RandyHayes
Super User
Super User

@rhamza 

Well before going too far, what is it that you are trying to accomplish?  I am only guessing from the picture in Message #9.  But I'd rather not guess it through and take you down the wrong road.

So, what is the purpose of the app, or at least this screen?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

The project is to have an application where employees could submit their idea whatever the type of idea it is and then other employees can vote on the idea they like the most

 

I have a page with new idea creation

 

On this page, it is an idea that you created but you saved it for later sort of acting like an edit form. the status of this idea in this case is at saved where as another idea with status submitted, you wouldn't be able to edit it, so lets say you created your idea you did not attach a product to it, you would return to this screen and add them

RandyHayes
Super User
Super User

@rhamza 

Thanks for the description!

I am a little confused then why the choice of a many to many relationship is needed.  Is the Idea submitted to be related to multiple products and that the product would have multiple ideas?

Just trying to get a better handle on your needs.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
rhamza
Helper V
Helper V

@AJ_Z 

 

Mate, I can't thank you enough. I've been chatting here for a long time and with other post and  I wasn't able to sort it out.  I spent literally 40hours on this problem

 

You went above the expectation with a real time meeting, spent 3h with me to find out that a microsoft feature doesn't allow me to filter properly. I'll let you post the solution here. ( Service quality 20 on 10 ! ) 

Good job mate !

I am so glad I was able to help with all of the issues and thanks so much for your kind words it really does mean a lot 🙂 !

The root cause of this issue links back to this setting once turned off an refreshed the issue was resolved:

AJ_Z_0-1642451425139.png

Once this was resolved the Items property of the Gallery functioned as expected and the schema issues were gone.

 

Thanks again for your kind words and good luck on your Power App Journey!!! 😄




If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !

RandyHayes
Super User
Super User

@rhamza 

I'm assuming since you mention @AJ_Z and about a one-on-one conversation off of the forum, that you have arrived at a solution.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
rhamza
Helper V
Helper V

@RandyHayes ,

 

Thx for your support mate! But yeah @AJ_Z  did a conference call with me and was able to resolve the issue. great support guys!

 

The community forum really needs to add a live chat, sharing screen feature etc... it makes things soooooo much easier...

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,617)