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

Clearing items from a Sharepoint List via powerapps

Hey, all!

 

I'm building a prototype PowerApp to help manage pool laptops. It's built from a list of available laptops in SharePoint, which is made up of several columns including computer name, common name, Recipient, Check-out Date, Return Due-Date, Reference Engineer, Request Reason.

 

The number of laptops is static, (so we don't need to add a new item to the list). But, there are several columns that include information that would be reset when the user returns the laptop. (i.e. Engineer Responsible, Recipient, Checkout Date, Return Date, Reason).

 

(I've added some pictures to this to give you a visualisation of what I mean.)

 

In short, I'm trying to find an appropriate way for our engineers to tick the relevant box in the gallery, then select returned to clear the Recipient, Engineer, Check-Out, Due-Date and Reason, so that it can then be reassigned using the form (that part seems to work fine).

 

So far I've played around with the Reset functions in PowerApps but I don't think this is the way forwards. I have started dabbling with the PowerAuto in order to achieve this, but I'm still quite green to it and not sure how I'd go about clearing or blanking specific columns in a row item (i.e. not clearing the computer name / common name).

 

Any ideas?

 

Cheers & Have a great day 🙂

4 REPLIES 4
Pstork1
Dual Super User
Dual Super User

I think what you are looking for is a simple Patch() statement in the OnSelect of the Returned button that clears the fields in the list.  For the checkbox set something in the OnChecked and OnUnChecked that sets or clears a variable to the value of the indexed field in the data source.  I'm assuming in your picture that is something like the 'UKL....' value that you display.  Then in the OnSelect do a Patch(datasourcename, Lookup(IDField=variable), {whatever values you want to reset})



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
v-xida-msft
Community Support
Community Support

Hi @RhysD ,

Do you want to clear the  Recipient, Engineer, Check-Out, Due-Date and Reason column value for the selected item(s) within the Gallery?

 

Based on the needs that you mentioned, I think the Patch function and ForAll function could achieve your needs. I have made a test on my side, please consider take a try with the following workaround:

1. Turn on the "Formula-level error management" option within Advanced settings of App settings of your app.

2. Set the OnSelect property of the "Returned" button to following:

ForAll(
       RenameColumns(Filter(Gallery1.AllItems, CheckBox1.Value = true), "ID", "ID1"),
       Patch(
             'Your SP List',
             LookUp('Your SP List', ID = ID1),
             {
                Recipient: Blank(),
                ReferenceEngineer: Blank(),
                CheckOutDate: Blank(),
                ReturnDueDate: Blank(),
                Reason: Blank()
             }
       )
)

Please take a try with above solution, check if the issue is solved.

 

Best regards,

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

Hey, that sort of helped - I did some editing using the online MS docs and now I've got the below:

 

Patch(PoolLaptopApp, (Gallery1.Selected), {Recipient: Blank(),ReferenceEngineer: Blank(),CheckOutDate:Blank(),ReturnDueDate: Blank(),Reason: Blank()})

 

This works, however I'm finding that if I select multiple entries and then hit returned, it only applies to the last entry selected. Any ideas how I might be able to remedy this so that it does it for all selected items? 

 

I did try:

 

ForAll(Patch(PoolLaptopApp, (Gallery1.Selected), {Recipient: Blank(),ReferenceEngineer: Blank(),CheckOutDate:Blank(),ReturnDueDate: Blank(),Reason: Blank()}))

 

But it returns the error "Invalid number of arguments: received, expected 2"

 

I'm not too sure what I'm missing.

 

All the best,

Rhys. 

Pstork1
Dual Super User
Dual Super User

Patch() by definition applies to a single record.  There are ways to do it using ForAll(), but as you've seen those are tricky.  Instead I would take a look at the UpdateIf() function. UpdateIf() applies to any record that meets the criteria specified.

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-update-updateif



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

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.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,626)