cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
nliu
Helper II
Helper II

Patch function

Hello,

 

I've 6 SPList which is related to one app, on my first screen people have to choose indirectly their SPList by choosing their department :

 

Bienvenue.jpg

 

When you clicked on it you navigate to a form, after filled it you have to submit the information by using the iconaccept, here the corresponding code : 

 

If(TargetDTECA = "DTECA" && TargetScreen3 = "NewForm";
Patch('ESU - CA';Defaults('ESU - CA');
{ 'Structuredelenduitsuperficiel': DataCardValue100.SelectedText.Value;
'Ville_x002f_Commune': DataCardValue101.Text;
'D_x00e9_partement': DataCardValue115.Selected;
'Typedeliant': DataCardValue113.Selected;
'Nomduliant': DataCardValue98.SelectedItems;
'P_x00e9_riodeder_x00e9_alisation': DataCardValue102.SelectedDate});

 

Patch('ESU - CA'; LookUp('ESU - CA';'Structure de l''enduit superficiel' = Title1.Text && 'Ville/Commune' = Subtitle1.Text && 'Période de réalisation' = DataCardValue102.SelectedDate);
{ 'Structuredelenduitsuperficiel': DataCardValue100.SelectedText.Value;
'Ville_x002f_Commune': DataCardValue101.Text;
'D_x00e9_partement': DataCardValue115.Selected;
'Typedeliant': DataCardValue113.Selected;
'Nomduliant': DataCardValue98.SelectedItems;
'P_x00e9_riodeder_x00e9_alisation': DataCardValue102.SelectedDate}));;


If(
TargetNEB = "DTENEB" && TargetScreen3 = "NewForm";
Patch('ESU - NEB';Defaults('ESU - NEB');
{ 'Structuredelenduitsuperficiel': DataCardValue100.SelectedText.Value;
'Ville_x002f_Commune': DataCardValue101.Text;
'D_x00e9_partement': DataCardValue115.Selected;
'Typedeliant': DataCardValue113.Selected;
'Nomduliant': DataCardValue98.SelectedItems;
'P_x00e9_riodeder_x00e9_alisation': DataCardValue102.SelectedDate});
Patch('ESU - NEB'; LookUp('ESU - NEB';'Structure de l''enduit superficiel' = Title1.Text && 'Ville/Commune' = Subtitle1.Text && 'Période de réalisation' = DataCardValue102.SelectedDate);
{ 'Structuredelenduitsuperficiel': DataCardValue100.SelectedText.Value;
'Ville_x002f_Commune': DataCardValue101.Text;
'D_x00e9_partement': DataCardValue115.Selected;
'Typedeliant': DataCardValue113.Selected;
'Nomduliant': DataCardValue98.SelectedItems;
'P_x00e9_riodeder_x00e9_alisation': DataCardValue102.SelectedDate}));;

 

If I choose on my first screen "DTECA" I would like to record the information only in the ESU-CA SPList and not in the other... I thaught with this formula it will be ok but at the end when I checked on SP it was recorded in every SPList...

 

What's wrong ? Can you please help me ?

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User
Super User

@nliu 

Hello there.  The problem will be with how you've conditioned your IF statements.  It is currently setup in a way such that both of these conditions are True.  That's why they are posting to all SharePoint lists.

 

If(TargetDTECA = "DTECA" && TargetScreen3 = "NewForm", ...)
If(TargetNEB = "DTENEB" && TargetScreen3 = "NewForm", ...)

 

To ensure only one list gets posted to you can use a common variable name for the target and change the value like this:

 

If(myTarget = "DTECA" && TargetScreen3 = "NewForm", ...)
If(myTarget = "DTENEB" && TargetScreen3 = "NewForm", ...)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

View solution in original post

2 REPLIES 2
mdevaney
Super User
Super User

@nliu 

Hello there.  The problem will be with how you've conditioned your IF statements.  It is currently setup in a way such that both of these conditions are True.  That's why they are posting to all SharePoint lists.

 

If(TargetDTECA = "DTECA" && TargetScreen3 = "NewForm", ...)
If(TargetNEB = "DTENEB" && TargetScreen3 = "NewForm", ...)

 

To ensure only one list gets posted to you can use a common variable name for the target and change the value like this:

 

If(myTarget = "DTECA" && TargetScreen3 = "NewForm", ...)
If(myTarget = "DTENEB" && TargetScreen3 = "NewForm", ...)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

View solution in original post

@mdevaney  it works perfectly ! Thank you !

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,618)