cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ALP1
Continued Contributor
Continued Contributor

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

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

ALP1
Continued Contributor
Continued Contributor

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
)

 

 

 

 

ALP1
Continued Contributor
Continued Contributor

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.

ALP1
Continued Contributor
Continued Contributor

thank you it's working 🙂

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors
Users online (1,332)