cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tusharmehta
Helper I
Helper I

Is it possible to check/search duplicate with collection before new data is getting stored

Hello Everyone, 

 

I am working on an office supply system and in that more than 200 items list. 

 

The user is allowed to select items from the gallery and stored them in the collection before final submission.

 

Here I would like to send the error to the user when he/she will select an item from the list again and send it for collection list submittion. 

 

Please share with me any example which can help me understand the process. 

 

 

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions

Hi @tusharmehta ,

I am guessing a bit here, but do you want to check that the value in the field Elocation does not already exist in the gallery?

If(
   !(ThisItem.Elocation in CollectionName.Elocation) || 
   !IsBlank(order_name.Text),
   Collect(
      MyCart,
      {
         ID: ThisItem.ID,
         OrdererName: order_name.Text,
         OrderDate: Now(),
         Quantity: Value(1),
         Product: ThisItem.offsupp_product,
         Measurement: ThisItem.Measurement,
         DefaultValue: ThisItem.default_value,
         Email: User().Email,
         Location:order_location.Text,
         ProductImgPath:ThisItem.prd_img_url,
         ProductImgUrl:ThisItem.img_url,
         Image: ThisItem.prd_img_url & ThisItem.img_url
      }
   ),
   Notify(
      "Check Location, Name, can't be blank close the Application and re-open again"
   )
)

 

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

Thanks to @WarrenBelz

 

The problem is in this line !(ThisItem.Elocation in CollectionName.Elocation)  The collection name is not recognizing..

View solution in original post

6 REPLIES 6
Ethan_R
Continued Contributor
Continued Contributor

Hi @tusharmehta ,

I assume that User is selecting item from Gallery but doesn't have visual knowledge whether the item is in collection or not.

If this is the case then you can add an indicator or templatefill for Gallery by checking if the Unique item ID is present in collection or not, rather than inserting into collection with duplicate records.

You can also check if similar records exist. 1 of the way is given by WarrenBelz reply on this Post.

 

Hope this helps.

v-qiaqi-msft
Community Support
Community Support

Hi @tusharmehta,

Have you solved your problem?

Do you want to check if the selected record from the Gallery duplicated?

Could you please share a bit more about the scenario, how you select multi records from the Gallery, using Checkbox?

 

I assume that you insert Checkbox into the Gallery to select multi records. To check if the selected record duplicated, you just need to set the OnCheck property of the Checkbox as below:

If(ThisItem in CollectionName,
  Notify("Selected Record Existed!",Error),
  <Your Patch formula>
)
Best Regards,
Qi

Thanks for the reply. 

 

I am forwarding the code which works fine without duplicate checking.

 

This application allows the employee to order office items from the gallary.  

 

If(!IsBlank(Elocation) || !IsBlank(order_name.Text),
Collect(
MyCart,
{
ID: ThisItem.ID,
OrdererName: order_name.Text,
OrderDate: Now(),
Quantity: Value(1),
Product: ThisItem.offsupp_product,
Measurement: ThisItem.Measurement,
DefaultValue: ThisItem.default_value,
Email: User().Email,
Location:order_location.Text,
ProductImgPath:ThisItem.prd_img_url,
ProductImgUrl:ThisItem.img_url,
Image: ThisItem.prd_img_url & ThisItem.img_url
}),
Notify("Check Location, Name, can't be blank close the Application and re-open again")
)
 

if I will have to follow your code I believe I will have to add a NOT IN with current if Condition correct, if yes update the code and send me the example. Because I am not able to use NOT IN. 

Hi @tusharmehta ,

I am guessing a bit here, but do you want to check that the value in the field Elocation does not already exist in the gallery?

If(
   !(ThisItem.Elocation in CollectionName.Elocation) || 
   !IsBlank(order_name.Text),
   Collect(
      MyCart,
      {
         ID: ThisItem.ID,
         OrdererName: order_name.Text,
         OrderDate: Now(),
         Quantity: Value(1),
         Product: ThisItem.offsupp_product,
         Measurement: ThisItem.Measurement,
         DefaultValue: ThisItem.default_value,
         Email: User().Email,
         Location:order_location.Text,
         ProductImgPath:ThisItem.prd_img_url,
         ProductImgUrl:ThisItem.img_url,
         Image: ThisItem.prd_img_url & ThisItem.img_url
      }
   ),
   Notify(
      "Check Location, Name, can't be blank close the Application and re-open again"
   )
)

 

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

Thanks to @WarrenBelz

 

The problem is in this line !(ThisItem.Elocation in CollectionName.Elocation)  The collection name is not recognizing..

View solution in original post

Hi @tusharmehta ,

Go to View > Collections > YourCollectionName and see what is in there

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,801)