Hi. I am new to Powerapps
I have developed a small app which updates a sql table via an on premise gateway. Right now it is connected to a dummy table containing a small amount of data.
I want to be able to declare the table/connection in a variable onStart so in future I would not have to go through each function to edit the DataSource.
Original code:
If(
CountRows(colTaskUpdates) > 0,
Patch(DataTable,colTaskUpdates);
);
Clear(colTaskUpdates);
Refresh(DataTable)
I changed it to this thinking there would be no issues
Set(myConnection,DataTable);
If(
CountRows(colTaskUpdates) > 0,
Patch(myConnection,colTaskUpdates);
);
Clear(colTaskUpdates);
Refresh(myConnection)
In the Patch function with my code I get this message: "The first argument of 'Patch' should be a collection".
although the refresh function works with the variable.
Reading through the documentation I still could not find the answer to why the variable can not be passed.
Thank you in advance
First, there is no need to issue a Refresh on your datasource. In PowerApps, your datasource will already reflect any changes you make. Issuing a refresh will just kill your performance.
Second, what you think is happening with the Refresh is not happening...it is not refreshing the datasource when in a variable.
Finally, you cannot use a variable as you are. You have to specifically define the datasource. Using variables like that is very "programmatic" - PowerApps is not a programming platform. It is not "code", it is just formulas like you would have in Excel (as it was designed after that).
I hope this is helpful for you.
@RandyHayes
Hi Randy. Thank you for your reply.
I understand your reply but it does not add up for me.
Finally, you cannot use a variable as you are.
I tried the variable in other functions as well. This one works.
Set(myConnection,DataTable);
SortByColumns(Search(
myConnection,
search_input.Text,
"Column1",
"Column2",
"Column3",
"Column4"
),"Column1")
Also this one
CountRows(myConnection)
So in the end for me it seems like it is only for the Patch function. And I still can not find an answer to why it is like this.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
199 | |
52 | |
41 | |
39 | |
35 |
User | Count |
---|---|
263 | |
86 | |
71 | |
69 | |
66 |