cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
CABIRD
Level: Powered On

Power apps gallery add new records to sharepoint list

I have a SharePoint Online (SPO) housekeeping audit list.

 

A Power app expanding gallery displays a number of audit questions.

 

User selects a radio button "Pass", "Fail", "N/A."

 

Users chooses "Fail" a description box appears. 

 

When user finishes audit user taps "Submit" button to send the data to SPO. 

PowerApp.png

SPO list should show questions and answers by user. 

SPO.png

I'm assuming best to keep one SPO list for questions. Another SPO list for user answered questions?  

 

I'm assuming Patch, or Collect all won't be able to capture all questions and answers and create new SPO record for each answered question. 

 

Can a gallery be used in this way? Can Flow be used?

 

A form doesn't really see to work for this requirement. I'd appreciate some thoughts.

 

Thank you.

 

Christopher 

1 ACCEPTED SOLUTION

Accepted Solutions
hnguy71
Level 8

Re: Power apps gallery add new records to sharepoint list

Hi @CABIRD ,
You should build your solution using two lists.

1. House all your questions in. If you require more or less questions, your gallery remains dynamic.

2. Collect answers from end-users.

 

I've done a test on my side using a CDS but you can do the same with SPO:
list1.png
List 2 should house all your answers:
list2.png

Your initial gallery items should be from your questions list (Checklists):
galleryitems.png
And inside your control's OnSelect property you should have a similar code:
forall.png
Upon a quick and dirty test these are my results:
cds_results.png

9 REPLIES 9
Super User
Super User

Re: Power apps gallery add new records to sharepoint list

Hi @CABIRD 

 

You could do a patch for each question in the gallery by using ForAll and Patch

 

When user clicks on submit button,

 

ForAll(GalleryQuestions.AllItems, Patch (CheckList, ....

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

CABIRD
Level: Powered On

Re: Power apps gallery add new records to sharepoint list

Hello @RezaDorrani 

 

I'll give it a go. Thank you for taking the time to respond and answer my question. I really appreciate you doing so. 

 

Spent most of the day attempting to find a way to implement the recommendation and failed see below. 

ForAll(Gallery.AllItems,Patch(Checklist, Gallery.Selected,{CheckStatus: RbtStatus.Selected.Value, Description: TxtDescription.Text})); Reset(Gallery)

ForAll.png 

Patch appears to work but not surprisngly only for active record for example cursor left in description and click patch button then that record is updated. Cannot understand why adding ForAll Gallery All Items fails. 

Patch(Checklist, Gallery.Selected,{CheckStatus: RbtStatus.Selected.Value, Description: TxtDescription.Text}); Reset(Gallery)

Collect fails completely.

Collect(Checklist, {AuditName: LblAuditName.Text, CheckStatus: RbtStatus.Selected.Value, Description: TxtDescription.Text}); Reset(Gallery) 

Really frustrating. 

 

Best regards.

Christopher

 

Super User
Super User

Re: Power apps gallery add new records to sharepoint list

Hi @CABIRD 

 

If you are trying to add records to your data source

 

ForAll(Gallery.AllItems,Patch(Checklist, Defaults(Checklist),{CheckStatus: RbtStatus.Selected.Value, Description: TxtDescription.Text}))

 

If you are trying to update for existing records

 

first create collection

ClearCollect(colNew,Gallery.AllItems);

 

Then update

ForAll(colNew,Patch(DataSource,LookUp(DataSource,Title = colNew[@Title]),{update fields}))

DataSource = your list 

colNew = new collection

Title = colNew[@Title]  - condition to fetch unique record to update

 

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

 

CABIRD
Level: Powered On

Re: Power apps gallery add new records to sharepoint list

Hello @RezaDorrani 

 

Thank you. I'll implement your suggestion. Apologise for delay responding. Windows 10 1903 update removed keyboard and mouse at log in. Implementing recovery resolved it but update reinstalled. Probably will have to rebuild. 

 

I appreciate you providing a more detailed answer. Have a magnificent day. 

 

Best wishes

Christopher

CABIRD
Level: Powered On

Re: Power apps gallery add new records to sharepoint list

Hello @RezaDorrani 

 

Apologise, after failed update my PC rebuild took much longer than I expected. I wanted to avoid a rebuild. If I had just got on with it I wouldn't have lost two days.  

 

1. I tried 

ForAll(Gallery.AllItems,Patch(Checklist, Defaults(Checklist),{CheckStatus: RbtStatus.Selected.Value, Description: TxtDescription.Text}))

ForAll.png

Unfortuantely failed to add records to data source. 

--------------------------------------------------------

2. Update existing records

ClearCollect(colNew,Gallery.AllItems); ForAll(colNew,Patch(DataSource,LookUp(DataSource,Title = colNew[@Title]),{update fields})) 

Didn't work for me either. 

Collection.png

Collect.png

 

Collect1.png

SPO.png

 

I'm assuming I require two SPO lists. One for questions. The first SPO list would allow for approved user to amend or add additional questions. The second SPO list for user answers. At present I have one list as I'm just trying to understand the principals of capturing the questions then writing back user answers. 

 

Thank you.

 

Regards

Christopher

 

 

 

Super User
Super User

Re: Power apps gallery add new records to sharepoint list

Hi @CABIRD 

 

In your add new items, there is an error (Red mark)

Hover on the error to read the message and see what is the issue

CABIRD
Level: Powered On

Re: Power apps gallery add new records to sharepoint list

Hello @RezaDorrani 

 

Thank you for replying. All very confusing. 

ForAll(Gallery.AllItems,Patch(Checklist, Defaults(Checklist),{CheckStatus: rbtStatus.Selected.Value, Description: TxtDescrSiption.Text}))

Error reads as follows.

This type of argument 'Description' does not match the expected type of 'Text'. Found type 'Error'. 

 

SPO1.pngSPO2.png

Power App rbtStauts (Pass: Fails: N/ASmiley Happy SharePoint CheckStatus single line of text. 

Power App Text input (Description). SharePoint Description column multi line text. 

 

Creating a collection then update simple doesn't work for me. I think it has to be the radio button as I can use a edit form to use radio button and pass data to SPO. Problem with edit form occurs when the checklist has forty questions to display, answer and submit. A gallery would be more efficent.   

 

Best wishes

Christopher

 

hnguy71
Level 8

Re: Power apps gallery add new records to sharepoint list

Hi @CABIRD ,
You should build your solution using two lists.

1. House all your questions in. If you require more or less questions, your gallery remains dynamic.

2. Collect answers from end-users.

 

I've done a test on my side using a CDS but you can do the same with SPO:
list1.png
List 2 should house all your answers:
list2.png

Your initial gallery items should be from your questions list (Checklists):
galleryitems.png
And inside your control's OnSelect property you should have a similar code:
forall.png
Upon a quick and dirty test these are my results:
cds_results.png

CABIRD
Level: Powered On

Re: Power apps gallery add new records to sharepoint list

Hello @hnguy71 

 

Thank you for taking the time to reach out and answer my question. I really appreciate you doing so. 

 

I discovered my rooky mistake. I shouldn't have made this blunder as I was more than aware of this error having made this same mistake in the past. 

 

Over the years I've learnt if you change the name of SPO default 'Title' column name this can cause all sort of issues and that was my mistake. Leaving 'Title' as is I found the patch worked perfectly.  

 

Have a fabulous day. 

 

Best wishes

Christopher 

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 176 members 3,886 guests
Recent signins:
Please welcome our newest community members: