Hi @Anonymous ,
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,