cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
EmmaH
New Member

Update a column in sql after validation

Hi,

I have two colums in SQL server.

The first one is filled directly with the form, the second one has to be filled under some conditions.

I have tried a Patch and an UpdateIf formulas. With the Patch it created a new record and the UpdateIf did not work.

My code for the Patch function is : 

SubmitForm(myForm);; 
Patch(
    '[dbo].[Test_Reclamations_Marketing]';
    {
        'Action_soldée_?_OUI_NON': If(
            IsBlank('[dbo].[Test_Reclamations_Marketing]'.Date_de_réponse_définitive);
            "NON";
            "OUI"
        )
    }
)

And for the UpdateIf :

SubmitForm(myForm);;
UpdateIf(
    '[dbo].[Test_Reclamations_Marketing]';
    IsBlank('[dbo].[Test_Reclamations_Marketing]'.Date_de_réponse_définitive);
    {'Action_soldée_?_OUI_NON': "NON"}
)


Am I doing something wrong ?


Thanks,

Emma

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @EmmaH ,

Do you want to create a new record and then update records?

Could you tell me

1)the meaning of "'[dbo].[Test_Reclamations_Marketing]'.Date_de_réponse_définitive"?

2)the data type of Date_de_réponse_définitive field?
3)your update rule? what kind of items do you want to update?

Please notice two things:
1)patch function is only used to update one record, not all the records that meet the requirements.

2)IsBlank() function is used to justify blank value. IsEmpty() function is used to justify blank table.

"tablename.fieldname" represents a table, not a field or value.

 

 

If you want to update those items that Date_de_réponse_définitive field is blank, then please try this:

SubmitForm(myForm);;
UpdateIf(
    '[dbo].[Test_Reclamations_Marketing]';
    IsBlank(Date_de_réponse_définitive);
    {'Action_soldée_?_OUI_NON': "NON"}
)

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
KD203
Helper II
Helper II

hi @EmmaH,
you can specify that you want to update a row with patch, when you specify a base record:

 PatchDataSourceBaseRecordChangeRecord1 [, ChangeRecord2, … ])
is the syntax that you can use, you can find a base record with lookup, or any other function that returns a single record.
You can read more here:
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch

hi @KD203 ,

Thank for your answer, but I've already looked at the documentation and tried to applicate it in my context and it's still not working. Maybe I made a mistake with the syntax?  

Since you are patching immediately after the submitform you can try this:

 

SubmitForm(myForm);
Patch(
    '[dbo].[Test_Reclamations_Marketing]';
    Last('[dbo].[Test_Reclamations_Marketing]');
    {
        'Action_soldée_?_OUI_NON': If(
            IsBlank('[dbo].[Test_Reclamations_Marketing]'.Date_de_réponse_définitive);
            "NON";
            "OUI"
        )
    }
)

 

 The last function returns the last record of the database.

v-yutliu-msft
Community Support
Community Support

Hi @EmmaH ,

Do you want to create a new record and then update records?

Could you tell me

1)the meaning of "'[dbo].[Test_Reclamations_Marketing]'.Date_de_réponse_définitive"?

2)the data type of Date_de_réponse_définitive field?
3)your update rule? what kind of items do you want to update?

Please notice two things:
1)patch function is only used to update one record, not all the records that meet the requirements.

2)IsBlank() function is used to justify blank value. IsEmpty() function is used to justify blank table.

"tablename.fieldname" represents a table, not a field or value.

 

 

If you want to update those items that Date_de_réponse_définitive field is blank, then please try this:

SubmitForm(myForm);;
UpdateIf(
    '[dbo].[Test_Reclamations_Marketing]';
    IsBlank(Date_de_réponse_définitive);
    {'Action_soldée_?_OUI_NON': "NON"}
)

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,204)