cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Data_Enthusiast
Post Patron
Post Patron

Restrict adding duplicated items

Hi Power Apps Community,

I am creating an app which is filtering the data in the Gallery against that user who is logged in.

I would like the users to add items to the SharePoint list - which is currently working, however they should be restricted into only being allowed to add a particular item once. Is this possible in Power Apps?

I would really appreciate any assistance.

Thank you in advance.

2 ACCEPTED SOLUTIONS

Accepted Solutions
gabibalaban
Dual Super User
Dual Super User

Hi @Data_Enthusiast ,

 

I think that the easiest way to achieve your goal is to put a condition with the Patch function on one of the brach.

So put on OnSelect property something ruled by this logic: 

 

If (newItemValue in Concat(YourList,ItemColumn),

           Notify("The Item is already in the list"),

           Patch(....)

    )

View solution in original post

HI @Data_Enthusiast ,

As a different approach, try this on the save button DisplayMode - assuming you have selected the item from a gallery.

If(
   LookUp(
      YourListName,
      ID = YourGalleryName.Selected.ID
   ).'Modified By'.DisplayName = User().FullName,
   DisplayMode.Disabled,
   DisplayMode.Edit
)

 

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

10 REPLIES 10
UdayAdhikari
Continued Contributor
Continued Contributor

Sure, but define "particular item". What defines particular item - perhaps, Title column or some other column with specific value. If so, one option is to call a flow on submit button that checks whether an item already exists for the passed value/s and return true/false. If item exists is true, display message to the end user otherwise continue with item creation from Power Apps. Add details if this I completely misunderstood your question 🙂

 

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.

Thanks

 

 

 

WarrenBelz
Super User
Super User

Hi @Data_Enthusiast ,

This issue is whether the user is the only one likely to edit the record. If so, you could check the user's name against the modified property and if the same, they have obviously been there. If multiple users, then you could store concatenate the email of everyone who saves to a multi-line text field and then check for the existence of the logged-in user.

 

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.

gabibalaban
Dual Super User
Dual Super User

Hi @Data_Enthusiast ,

 

I think that the easiest way to achieve your goal is to put a condition with the Patch function on one of the brach.

So put on OnSelect property something ruled by this logic: 

 

If (newItemValue in Concat(YourList,ItemColumn),

           Notify("The Item is already in the list"),

           Patch(....)

    )

@UdayAdhikari 

Interesting, I did not consider using a Flow. I think I used 'particular' loosely. It is a column which is a lookup to a list of items.

@WarrenBelz 

The item will only be edited by one person. How would I check against the modified property?

Hi @gabibalaban 

I ran into an error using this approach:

Data_Enthusiast_0-1604649964963.png

The fields are within a Form. 'Datacardvalue.selecteditems.value' - the error is highlighted on the '.value' part.

gabibalaban
Dual Super User
Dual Super User

@Data_Enthusiast ,

I'm a little bit confused, The selecteditems property returns all items selected from a combobox control /list box (controls that allow to select multiple items)...Are you trying to update multiple Items ?  If not, please use Datacardvalue.selected.value instead.

HI @Data_Enthusiast ,

As a different approach, try this on the save button DisplayMode - assuming you have selected the item from a gallery.

If(
   LookUp(
      YourListName,
      ID = YourGalleryName.Selected.ID
   ).'Modified By'.DisplayName = User().FullName,
   DisplayMode.Disabled,
   DisplayMode.Edit
)

 

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.

@gabibalaban 

Thank you! Your code worked 🙂

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 (2,309)