cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ale100
Frequent Visitor

Check if a item in a a gallery has the same value

I have a gallery that contains problems or issue of an animal. I can add problems to the animals as long as is not the same problem twice (so let say an horse has a limping, we don't need to add 2 limping if 2 of their legs limps we can just add one and say if for the whatever leg is in a text field).What i tried to achieve is when i edit a problem, i want a validation that check if  there no duplicate of the same problem.

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @ale100 ,

Firstly you would need to define all the possibilities and put them in a drop-down. You could then check with a Lookup on the OnChange of the drop-down

If(
   !IsBlank(
      LookUp(
         YourListName,
         YourInjuryField=Self.Selected.xxxx
         && ID=ThisItem.ID
      )
   ),
   Notify("Injury already recorded",Error);
   Reset(Self)
)

 xxxx will depend on the Items of the drop-down.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

2 REPLIES 2
WarrenBelz
Super User
Super User

Hi @ale100 ,

Firstly you would need to define all the possibilities and put them in a drop-down. You could then check with a Lookup on the OnChange of the drop-down

If(
   !IsBlank(
      LookUp(
         YourListName,
         YourInjuryField=Self.Selected.xxxx
         && ID=ThisItem.ID
      )
   ),
   Notify("Injury already recorded",Error);
   Reset(Self)
)

 xxxx will depend on the Items of the drop-down.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

I did something similar like this. the update context is use to change a variable that disable the save button and show a error text.

 

 

Set(VarRecord;Filter(DetailProbleme;ChevauxID.Id=ChevalDetail.ID And ID<>ThisItem.ID ));;
If(!IsBlank(LookUp(VarRecord;
ProblemeID.Id =EditproblemeDropdown.Selected.Id));
UpdateContext({Test:true});
UpdateContext({Test:false})
);;

 

 

it work well, as you can see the save button is disable when one of them is modify.probleme1_1.PNG

However, after some testing i found out that when i changed both to be the same new injurie, it doesn't workCapture1_2.PNG

I could also try to edit one injurie at the time, but i don't know how to do that in a gallery.

Edit: A solution that I'm trying is add a column in the gallery items like Items = 

 

AddColumns(Filter(DetailProbleme;ChevauxID.Value=ChevalDetail.ID);"IsEditing";false)

 

 But i still had more issue that when i patch the item, it said that "IsEditing" doesn't exist. 

Edit Edit: I did find a solution to edit one injurie at a time, i'll apply a validation that only one injurie can be edited 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,834)