cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ALP1
Post Patron
Post Patron

Prevent a patch if record already exists

Hi,

 

I've read this thread before i post https://powerusers.microsoft.com/t5/Building-Power-Apps/Prevent-a-patch-if-record-already-exists/m-p...

 

I have a Sharepoint list with a colum Name "Nom et prénom"

 
 
 

Annotation 2020-07-08 160813.png

 
 

Annotation 2020-07-08 161022.png

 

On my apps i add this

 

And finally on the sumit icon, i add this syntax

 

Annotation 2020-07-08 161615.png

 

I don't why i have this warning. 

Is because my column "Nom et prénom" is a person column ?

Thanks for your help

 

 

15 REPLIES 15
v-siky-msft
Community Support
Community Support

Hi @ALP1 ,

 

That is because that you use Patch with the Defaults function, which is intended to create records. Reference: Patch function 

 

If you want to make modification, the Base Record should be the Record you try to modify, which should be the Items property of Form.

For Example, if the EditForm Items property is Gallery1.Selected, then Patch formula should be like this:

Patch(
'Test QCM'; 
Gallery1.Selected;
EditForm1.Updates;
EditForm2.Updates
)

Just try to replace the Defaults('Test QCM') by the code in Items property of Form.

Hope this helps.
Sik

Hi, 

Sorry for the delay.

 

I use this syntax

 

If(IsBlank(LookUp('Formulaire Digital Formateurs';'Votre nom'=Votre_nom_DataCard2.text));
Patch('Formulaire Digital Formateurs'; Defaults('Formulaire Digital Formateurs');
EditForm1.Updates;EditForm2.Updates);
Patch('Formulaire Digital Formateurs';LookUp('Formulaire Digital Formateurs';'Votre nom'=Votre_nom_DataCard2.Text;EditForm1.Updates;EditForm2.Updates);;
Navigate(Success;ScreenTransition.Fade)

 

 

but i'm note sure with 

Title=TitleDatacard.Text

Is title is Votre_nom_Datacard2 ?

 

 

title.png

 
 

 

 

 

Hi @ALP1 

It looked like there were some syntax errors in  your formula.  See if this works for you

 

With({'Formulaire Digital Formateurs':FDF});
If(
   IsBlank(
           LookUp(FDF;'Votre nom' = Votre_nom_DataCard2.Text
           )
    );
    Patch(
          FDF; Defaults(
                         FDF
                ); EditForm1.Updates; EditForm2.Updates
     );
    Patch(
          FDF; LookUp(
                       FDF;'Votre nom' = Votre_nom_DataCard2.Text ;
                 ); EditForm1.Updates; EditForm2.Updates
                                            
      )
);;
Navigate(
         Success;ScreenTransition.Fade
)

 

 

 

 

You're right. I forgot ) in the syntax

 

ALP1_0-1594884698474.png

 

I still have errors (only 4)

 

ALP1_1-1594884776137.png

I think it comes from the type of field Votre nom.

In SharePoint, this column Votre nom is a Person or group type

 

ALP1_2-1594884985999.png

In PowerApps, i have this

ALP1_3-1594885128733.png

if i click on DatacardValue, i have this

 

ALP1_4-1594885299394.png

 

I don't have the option .text 

And I think that's where my mistake came from.

 

So I changed my syntax like this

 

ALP1_5-1594885683974.png

Now I have 2 errors because i don't know what to add after DatacardValue10. 

 

do you have an idea ?

@ALP1

I think DataCardValue10.Selected.Value

But check the Update property of the card containing the control.

View solution in original post

thank you it's working 🙂

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

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

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

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.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

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