cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AppsCreator
Regular Visitor

Unable to save all the datacard values into save button

Hello,

I'm new to PowerApps and trying to find a way to solve my issue. I've a SharePoint list from which I want users to lookup,edit or add data. The only issue is I cannot use the SP list directly cause it gives me a simple form that's not what the business folks need. They have a template as seen in the screenshot that they want to store the data in.

I created a scrollable canvas app and from the main screen I want to go into next screens based on if the user wants to add data or lookup or edit. For this I used multiple DataCard and in each datacard there's data field that's connected to the sharepoint list fields (eg. Name field in SP list is corresponding to Name filed in powerapps by "Patch(SP_List, {Name:TextInput1}))")

The issue is I'm trying to gather all the field values from all this datacards and store it in the SP list by using a Save button. In the same way I need to edit all those fields or lookup all those fields from the same custom template that's created.

How can I achieve this? Is there a simpler way to do it by using the same format of the word template that we have?

 

Appreciate your help in this regards!

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Re: Unable to save all the datacard values into save button

Hi @AppsCreator ,

Could you please share a bit more about your scenario?

Do you want to use the same template to add, view or edit records in your SP List?

 

Based on the needs that you mentioned, I think PowerApps could achieve your needs. If you want to add new record into your SP List, you need to reset all data card controls within this template firstly. And you need to set up a variable to store the current operation status (New, Edit or View).

Add a "+" button within your template, set the OnSelect property to followingh:

Reset(TextInput1);
Reset(TextInput2);
...
Reset(Dropdown1);
...;
Set(OperationStatus, "New")

Add a "Edit" icon within your app template, set the OnSelect property to following:

Set(OperationStatus, "Edit")

Add a "View" button within your app template, set the OnSelect property to following:

Set(OperationStatus, "View");

 

Set the Default property of the TextInput1 to following:

If(
   OperationStatus = "Edit" || OperationStatus = "View",
   LookUp('YourSPList', PrimaryColumn = "specific value").Column1   /* <-- retrieve the record you want to edit, then get the corresponding column value */
)

Set the Default property of the TextInput2 to following:

If(
   OperationStatus = "Edit" || OperationStatus = "View",
   LookUp('YourSPList', PrimaryColumn = "specific value").Column2
)

...

...

 

Set the OnSelect property of the "Submit" button to following:

If(
   OperationStatus = "New",
   Patch(
         'YourSPList',
          Defaults('YourSPList'),
          {
              Name: TextInput1.Text,
              ...
          }
   ),
   OperationStatus = "Edit",
   Patch(
         'YourSPList',
          LookUp('YourSPList', PrimaryColumn = "specific value"),
          {
            Name: TextInput1.Text,
            ...
          }
   )
)

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

 

In addition, I also think the standard Forms control (Display form & Edit form) in PowerApps could also achieve your needs. You could consider create your app using the standard Forms control, connect the Form control to your SP list, then these fields from your SP list would be generated as field data cards within the Edit form automatically. You could also add custom data card within the Form cnotrol. More details about Form controls in PowerApps, please refer to the following link:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/working-with-forms

 

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.

View solution in original post

4 REPLIES 4
Super User
Super User

Re: Unable to save all the datacard values into save button

Hi, are you suggesting you do not want to use the standard forms that come with PowerApps? If so, you can create your own datacards and create your own form. For saving any edits, you would have to use Patch instead of SubmitForm. Let me know if this is in line with your question and I can share more details. 

Community Support
Community Support

Re: Unable to save all the datacard values into save button

Hi @AppsCreator ,

Could you please share a bit more about your scenario?

Do you want to use the same template to add, view or edit records in your SP List?

 

Based on the needs that you mentioned, I think PowerApps could achieve your needs. If you want to add new record into your SP List, you need to reset all data card controls within this template firstly. And you need to set up a variable to store the current operation status (New, Edit or View).

Add a "+" button within your template, set the OnSelect property to followingh:

Reset(TextInput1);
Reset(TextInput2);
...
Reset(Dropdown1);
...;
Set(OperationStatus, "New")

Add a "Edit" icon within your app template, set the OnSelect property to following:

Set(OperationStatus, "Edit")

Add a "View" button within your app template, set the OnSelect property to following:

Set(OperationStatus, "View");

 

Set the Default property of the TextInput1 to following:

If(
   OperationStatus = "Edit" || OperationStatus = "View",
   LookUp('YourSPList', PrimaryColumn = "specific value").Column1   /* <-- retrieve the record you want to edit, then get the corresponding column value */
)

Set the Default property of the TextInput2 to following:

If(
   OperationStatus = "Edit" || OperationStatus = "View",
   LookUp('YourSPList', PrimaryColumn = "specific value").Column2
)

...

...

 

Set the OnSelect property of the "Submit" button to following:

If(
   OperationStatus = "New",
   Patch(
         'YourSPList',
          Defaults('YourSPList'),
          {
              Name: TextInput1.Text,
              ...
          }
   ),
   OperationStatus = "Edit",
   Patch(
         'YourSPList',
          LookUp('YourSPList', PrimaryColumn = "specific value"),
          {
            Name: TextInput1.Text,
            ...
          }
   )
)

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

 

In addition, I also think the standard Forms control (Display form & Edit form) in PowerApps could also achieve your needs. You could consider create your app using the standard Forms control, connect the Form control to your SP list, then these fields from your SP list would be generated as field data cards within the Edit form automatically. You could also add custom data card within the Form cnotrol. More details about Form controls in PowerApps, please refer to the following link:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/working-with-forms

 

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.

View solution in original post

AppsCreator
Regular Visitor

Re: Unable to save all the datacard values into save button

Thank you for the detailed explanation 🙂 The reset worked perfectly fine.

The issue I still have is I'm unable to save the data. When I fill the fields and save the data it stores empty result in my SP list. However, if I make any changes to date it's able to recognize that. Please see the screenshot attached.

for the field NameInput_1 the OnSelect property I've is Patch(SP_List, {Name:Value(NameInput_1.Text)}) and on the save button the command that I've applied to test few fields is 
If(
OperationStatus = "New",Patch(SP_List, Defaults(SP_List),{Name:Value(NameInput_1.Text),Date:DatePicker1_1.SelectedDate,Carrier:Value(CarrierNoInput_2.Text),TrailerNo:Value(TrailerNo.Text)});Navigate(HomeScreen,Fade)).

AppsCreator
Regular Visitor

Re: Unable to save all the datacard values into save button

Actually, scratch that I see where I was wrong. While saving i was using Patch(SP_List, Defaults(SP_List),{Name:Value(NameInput_1.Text)}) which was causing it to save null entry. When I removed the Value from the formula it saved perfectly.

Now the issue I'm stuck with is it is unable to fetch data from SP list and show on the document 😄

Can you suggest me something on it?

 

Thank you so much for your help in this regards 🙂

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

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!

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