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

Re: Clearing items from a Sharepoint List via powerapps

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.
Community Support
Community Support

Re: Clearing items from a Sharepoint List via powerapps

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.
RhysD
Frequent Visitor

Re: Clearing items from a Sharepoint List via powerapps

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. 

Dual Super User
Dual Super User

Re: Clearing items from a Sharepoint List via powerapps

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
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

‘Better Together’ T-Shirt Contest – Winner Announced!

‘Better Together’ T-Shirt Contest – Winner Announced!

And the winner is...

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

Top Solution Authors
Top Kudoed Authors
Users online (6,037)