cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Canadiansal
Helper V
Helper V

Collection

I build this app-based on a SharePoint List.

Here is my list with 3 columns:

Canadiansal_0-1607664103877.png

my requirement: when the users open the records in the edit screen, they can change the Person Column. And this change will be created as a new record in the list. The original record will say intact.

On start of the App, I create a collection with this Code:

ClearCollect(
ColDemo,
ShowColumns(
Table(Defaults('Test')),
"Title",
"Column1",
"Column2"
)
);
Clear(ColDemo)

 

And on the On Select of the IconAccept on the Edit screen, I have this Code:

Collect(
ColDemo,
{
Title: txtTitle.Text,
Column1: txtColumn1.Text,
Person: txtPerson.Selected
}
)

Canadiansal_1-1607664429863.png

 

I am actually following along with a youtube video, and maybe missing a few steps here. Currently, the application does nothing - no changes are saved to the list. Where do I need to look?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

@Canadiansal 

Rather than to worry about all those intermediary Collections, instead just

1) add the SharePoint List as a data source directly in your Canvas App, then

2) add a single Button Control to the app and finally

3) simply add this formula below in your OnSelect property of that Button:

 

 

Patch(TitleColumnPersonList,LookUp(TitleColumnPersonList,Title = "Test1"),{Person:TextInput1.Text})

 

 

 

and that is all. See if this works better for you.

 

The response above is presuming the following:

 

SharePoint List called TitleColumnPersonList (use the name of your SharePoint List instead).

 

tcp-shplist0925.png

 

Tested by us - actual result in SharePoint List after the button is clicked in Canvas App:

 

tcp-shplist0925-result.png

  Notice - that only Person column was changed of only that first  row / record!

See it in action below as well:

TitleColumn1PersonApp009-a1.gif

 

The example above also presumes:

 

One Text Input control called TextInput1 for the TextInput1.Text part of the Patch formula. This can just be something else entirely in your case, obviously - you can even just hard code a string value there instead first when practicing.

 

The Gallery1 being there and hooked to the SharePoint List data source in the visual example above is not presumed or required - it is only there to show it visually in action and that it is working to Patch only the one column in the one record from SharePoint List. 

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

PS: Just noticed you meant to create new record based on original record. So do it like this instead for that way:

 

Screen1 OnVisible:

Set(_BaseRecord,LookUp(TitleColumnPersonList,Title = "Test1"))

In this simple example we set one record to the variable on screen visible. You could easily instead adapt this example and Set that variable from another trigger, such as to select a specific record instead from a Gallery, and use the Lookup accordingly there in that property.

 

Button1 Patch:

Patch(TitleColumnPersonList
,
   {Title: _BaseRecord.Title, Column1: _BaseRecord.Column1, Person: TextInput1.Text}
)

 

 

Version in action that we think you really wanted:

 

TitleColumn1PersonApp009-a2.gif

 

 

 

Check if the above helps you @Canadiansal .

 

View solution in original post

2 REPLIES 2

@Canadiansal 

Rather than to worry about all those intermediary Collections, instead just

1) add the SharePoint List as a data source directly in your Canvas App, then

2) add a single Button Control to the app and finally

3) simply add this formula below in your OnSelect property of that Button:

 

 

Patch(TitleColumnPersonList,LookUp(TitleColumnPersonList,Title = "Test1"),{Person:TextInput1.Text})

 

 

 

and that is all. See if this works better for you.

 

The response above is presuming the following:

 

SharePoint List called TitleColumnPersonList (use the name of your SharePoint List instead).

 

tcp-shplist0925.png

 

Tested by us - actual result in SharePoint List after the button is clicked in Canvas App:

 

tcp-shplist0925-result.png

  Notice - that only Person column was changed of only that first  row / record!

See it in action below as well:

TitleColumn1PersonApp009-a1.gif

 

The example above also presumes:

 

One Text Input control called TextInput1 for the TextInput1.Text part of the Patch formula. This can just be something else entirely in your case, obviously - you can even just hard code a string value there instead first when practicing.

 

The Gallery1 being there and hooked to the SharePoint List data source in the visual example above is not presumed or required - it is only there to show it visually in action and that it is working to Patch only the one column in the one record from SharePoint List. 

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

PS: Just noticed you meant to create new record based on original record. So do it like this instead for that way:

 

Screen1 OnVisible:

Set(_BaseRecord,LookUp(TitleColumnPersonList,Title = "Test1"))

In this simple example we set one record to the variable on screen visible. You could easily instead adapt this example and Set that variable from another trigger, such as to select a specific record instead from a Gallery, and use the Lookup accordingly there in that property.

 

Button1 Patch:

Patch(TitleColumnPersonList
,
   {Title: _BaseRecord.Title, Column1: _BaseRecord.Column1, Person: TextInput1.Text}
)

 

 

Version in action that we think you really wanted:

 

TitleColumn1PersonApp009-a2.gif

 

 

 

Check if the above helps you @Canadiansal .

 

Thank you. This is very helpful!

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors
Users online (1,479)