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

Hide item in gallery when a new item is created out of it

Hello,

 

I have a gallery that displays items from a sharepoint list, there is button on each gallery item which opens a new form for the user to create an item in a different list. How do i disable or hide that item in gallery for that particular user when a new item is created based off it. The item should be disabled or hidden everytime the app is accessed by that user.

 

Thanks,

4 REPLIES 4
Drrickryp
Super User II
Super User II

Hi @ck25415,

It looks like you want everyone other than the user who created a new item in a second list to see everyone elses items.  If that is so, go into SharePoint, add a column to your list called NewItem and with the Column Type "Yes/No".  Set the default to "No".  In the OnSuccess property of your new form add the following 

Patch(YourSharepointlist,Lookup(YourSharepointList,ID= Gallery1.Selected.ID,{NewItem:true}))

Where YourSharepointlist is the list in the Items property of the gallery and Gallery1 is the name of the gallery with the button.

Filter the Items property of the Gallery for the logged in user with User(). and for items that have already been added to the second list as follows: (You will get a delegation warning but you can ignore it if your list is <2000 items.)

Filter(YourSharepointList,User().FullName <> 'Modified By'.DisplayName && NewItem=true)

Your gallery should only show the Item if a user other than the one who modified the item is looking at the list. If you put a toggle in the gallery with the Default property of NewItem.  It will show that a item has been added to the new list. You could also hide the button if the item has already been added to the new list by someone else if you set the Visible property of the button to !NewItem.  

 

I may be misunderstanding your requirements.  If you want the item in the gallery to be invisible to everyone once a new item is added to a second list, the Filters would be different. 

 

Hello @Drrickryp,

 

Thanks for the quick reply. Sorry for not posting the question clearly. In the second list I want only the user to see and edit his item so I will be suing the sharepoint default read and create-edit access option. I will need that item level permission as I want to enable the user to view and edit only his item in a edit form on a different screen. Also, the  list may contain more than 2000 items and I want to avoid delegation error by making sharepoint do the filter rather than me using filter option in powerapps.

 

Once a user creates a new item in second list, the item in gallery should be invisible to this particular user as other users will be creating new items based on the gallery item.

 

Thanks,

v-monli-msft
Community Support
Community Support

Hi @ck25415,

 

Did you mean that you want the user to be able to edit the record when first time loading the app, but disable editing when user finish updating one record? If so, then you could set below formulas for this app:

Screen1.OnStart=Set(V,true)
Gallery1.Visible=V
Button1(Submit Button for the Edit Form).OnSelect=SubmitForm(EditForm1);Set(V,false)

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello @v-monli-msft,

 

Thanks for the reply, I want the gallery to be in edit mode even after the user create/updates one record. Below image shows the gallery, user clicks on create next to first item and a new form opens to create a record in a different list. After submitting the form, user comes back to gallery and I want the first item in the gallery to be hidden or dsiabled to this particular user.

 

gallery.JPG

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

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

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