cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
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
Hugh1
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.

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

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

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

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]'?

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

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
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,616)