cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Patch Function Doesn´t update the SQL

Hello,

I´m trying to create an "Update Status" Button in my APP that will update a field in a row of SQL Table.

The function used was:

Patch( '[dbo].[dbo_ft]'; First( Filter( '[dbo].[dbo_ft]'; fno=Value(DataCardValue13.Text) ) ); {fref:"2"})

When clicked the button, the action occurs with no errors but the field "fref" in the SQL table doesn´t update to the value "2".

Anyone knows what could be the problem?

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Patch Function Doesn´t update the SQL

Hi @Anonymous 

Unfortunately, PowerApps doesn't support SQL Server tables with queries so I think that's the cause of the problem.

There's a post in the ideas forum that you can vote on.

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Using-SQL-Trigger-on-On-Prem-where-PowerApps-updates-columns/idi-p/334328 

View solution in original post

8 REPLIES 8
Highlighted
Frequent Visitor

Re: Patch Function Doesn´t update the SQL

Try using this formula. I have removed the semi colon and replaced it with a comma.

Patch( '[dbo].[dbo_ft]',
First(
Filter( '[dbo].[dbo_ft]',
fno=Value(DataCardValue13.Text)
)
),
{
fref:"2"
}
)

 

If this still doesn't work try filtering on the ID column to get the record that you want.

Highlighted
Community Support
Community Support

Re: Patch Function Doesn´t update the SQL

Hi @Anonymous ,

 

What is the date type of these fields?

It seems there is no mistake in your formula. It could be some connection error.

Could you please follow  these steps and check if your issue is fixed?

1. delete the SQL connection

2. re-login Gateway

3. clear the browser cache

4. re-add the connection

Sik

Highlighted
Super User
Super User

Re: Patch Function Doesn´t update the SQL

Hi @Anonymous 

To diagnose this problem, I would first check that PowerApps can find the target record that you want to update.

To do this, I would add a label to your screen and set the Text property to this:

First( Filter( '[dbo].[dbo_ft]'; fno=Value(DataCardValue13.Text) ) ).fno

Does the label show the correct fno value? If not, this is where the problem lies.

 

@Hugh1 - in case you're interested, in certain non English locales, the semi-colon character is the correct alternative to the comma character. There are some more details here...

https://powerusers.microsoft.com/t5/Building-Power-Apps/Combining-2-actions-for-a-Button/td-p/84030 

Highlighted
Anonymous
Not applicable

Re: Patch Function Doesn´t update the SQL

Hi @timl ,

 

When set the label properties with the expression

First( Filter( '[dbo].[dbo_ft]'; fno=Value(DataCardValue13.Text) ) ).fno

it doesn´t show the correct value.

But if point just just to the value field:

Value(DataCardValue13.Text)

the correct value appears.. So the problem is with the filter expression for the DB.

Any suggestion for the diagnose?

Thank You

Highlighted
Anonymous
Not applicable

Re: Patch Function Doesn´t update the SQL

The SELECT query in SQL shows me the correct row to filter:

SELECT *
FROM dbo.ft
WHERE fno=20000068

Highlighted
Super User
Super User

Re: Patch Function Doesn´t update the SQL

Hi @Anonymous 

Some of the things I would try are...

If you hardcode the criteria value into the Filter expression, does that return the correct fno value?

First( Filter( '[dbo].[dbo_ft]'; fno=20000068) ) ).fno

Alternatively, you could try using the LookUp function instead of First/Filter. Does that make a difference?

LookUp( '[dbo].[dbo_ft]'; fno=20000068)

Just to clarify the table name in your previous message (ie SELECT * FROM dbo.ft), could confirm that your table you want to use is '[dbo].[dbo_ft]', rather than '[dbo].[ft]'?

Highlighted
Anonymous
Not applicable

Re: Patch Function Doesn´t update the SQL

Hi @timl ,

 

With the Lookup funcion works just fine. Thank´s

 

Patch( '[dbo].[dbo].[ft]'; LookUp('[dbo].[dbo].[ft]'; fno=Value(DataCardValue13.Text) ) ; {fref:"2"})

 

But now i'm receiving the error message when i execute the button request:

"The target table of DML Statement Cannot have any enabled trigger if the statement contains an output clause without INTO clause."

Do you know if in tables with triggers we can execute this procedures?

Thank You

Highlighted
Super User
Super User

Re: Patch Function Doesn´t update the SQL

Hi @Anonymous 

Unfortunately, PowerApps doesn't support SQL Server tables with queries so I think that's the cause of the problem.

There's a post in the ideas forum that you can vote on.

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Using-SQL-Trigger-on-On-Prem-where-PowerApps-updates-columns/idi-p/334328 

View solution in original post

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (3,326)