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 III
Super User III

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 III
Super User III

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (67,009)