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

How to save data in a sharepoint list based on the user selection?

Hello,

I'm new to Power App and trying to build my first App. 

The requirement is the user needs to fill out a form to request some information. 

I have a sharepoint list collecting the basic information about the user and understanding the request. This part was easy. I created a form in Power app and collected the information in the sharepoint list.

Another sharepoint list has rows of data elements the user is requesting. Basically we expose a list to the user and the user can select what information it needs. For this I created a gallery, which expose the information to the user. Screenshot attached. 

PoojaG_0-1596559558859.png

The checkbox gives user the functionality to chose the data. Now here the complication begins. Once the user selects this data using the checkbox, All the selected options should be saved in a separate SharePoint list along with the master id from the form, so we know who needs/selected what data. Is this achievable? Please guide. thank you!!!

1 ACCEPTED SOLUTION

Accepted Solutions

@PoojaG please try this

Patch('User Data Element', Defaults('User Data Element'),{'Unique ID':from3.LastSubmit.ID},{'Data Element':Concat(colSelectedReq,email,",")})

Eg: Address Line 4, Address postal code

This creates the record in 3rd SP List, with the selected requirements from the gallery as comma separated.

View solution in original post

20 REPLIES 20
krishnags
Super User
Super User

@PoojaG so, you have two list, one is to collect basic information and another is to capture requirements selected by the user. Both the lists are getting submitted parallelly, please confirm.

@krishnags , You are right about the first list. However, the second list is basically just a table with information user can access and select what he wants. When he selects the records from the second list, I want to create a third list which stores the user selection. Does that makes sense? 

So, on request submission (basic information) to the first list, capture the details submitted. So, now when user selects the requirements from the second list, send the submitted requests details to SP and create record in 3rd list. It goes this way...

  1. SubmitForm(fromForFirstList)
  2. OnSuccess of the fromForFirstList properties, collect the data into a variable or collect. OnSuccess -> ClearCollect(submittedData,fromForFirstList.LastSubmit)
  3. Navigate user to 2nd List to chose the requirements and on the submit form of the 2nd List include the related data from submittedData collection

Basically we need the submitted data details to map to the 3rd list. You can follow the above approach or redirect user to a screen with the requested details in a gallery. On selection of a gallery item, you can navigate them to another screen to chose requirements from 2nd list and submit the data to 3rd list with the gallery.selected.ID (ID is the column from 1st list). So, 3rd list gets updated with the 1st list mapping

 

Hope this helps you

@krishnags  thanks for your response. I think I wasn't very clear with my requirement. How do I make user select items from the 2nd list in first place? The user can select more than one record from the data column. So I thought using gallery was the best way. I didn't understand your 3rd point. Let me share the screenshot of my app created so far so you may get a better idea of the process.

1st screen: I ask the user whether they want to submit a request or view their request. Let's say the user selects submit new request

PoojaG_0-1596569954584.png

2nd Screen: A form control is used where the user provide some information. There are lot of questions asked here. This is just a part in the screenshot. there is a next button which navigates them to the 3rd screen. Will skip that, as that's another set of information gathered. Clicking next takes us to the 4th screen

PoojaG_1-1596570043928.png

4th Screen: This is where the issue is. Have used a gallery control and connected to sharepoint where 2nd list data is stored. You see a select checkbox is added after each item. This is where I want to provide the user to select the data they require. After checking the checkbox, how can we store this information to another list? 

5th Screen: This is where the user completes the request process. It has buttons to save the data back in sharepoint. Works for screen2 and screen3.

Does that makes sense?

PoojaG_2-1596570223767.png

 

 

 

I prefer this way...

take a collection on selected items from the gallery.

on the last screen (5th). SubmitForm(fromForFirstList);Patch(3rdList,Defaults(3rdList),{reference:fromForFirstList.LastSubmit.ID},{'Active Directory Account': collection.ActiveDirectoryAccount})

 

Hope this helps

Not exactly sure what you mean, but I still followed your formula on the submit button and I get couple of wiggle lines. Specially for the reference and Collection. Did we create that earlier? 

PoojaG_0-1596571609802.png

 

@PoojaG the expression shared was only for your reference, since I don't have visibility to the fields.

 

  1. reference is the field in the 3rd list which holds 1st list record details
  2. Collection is something I was referring to the selected items from the gallery (requirements). Below is the reference to collect the data. You can replace Email with the respective field of yours.

On Check of the Check Box: Collect(colSelectedReq,{email:ThisItem.Email})

On uncheck of the Check Box : Remove(colSelectedReq,LookUp(colSelectedReq,email=ThisItem.Email))

 

@krishnags  thank you for patiently answering all my questions. I think I'm getting close. I was able to create the collection and store the user selected option. Now on the submit button, I'm still getting the wiggle line. The issue is around the data type. The Data Element column created on Sharepoint list 3 is a text field. 

PoojaG_0-1596573729863.png

 

@PoojaG yeah it might be due to data type issue. Since you are using a gallery to capture the data and to store in 3rd list, I guess you will be having required fields in place to capture the data (selected from the gallery).

 

For testing purpose, you can try

Patch('User Data Element', Defaults('User Data Element'),{'Unique ID':from3.LastSubmit.ID},{'Data Element': Text(First(colSelectedReq).'Data Elements')})

 

In the above snippet we are retrieving only first record from the colSelectedReq and updating it in 'Data Element" field

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 Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (35,368)