cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tguihur
Helper I
Helper I

If inside a Patch function

Hi all,

 

I have 2 dropdown lists, what I want is that if someone select "z-Autre"  my app should save the output in the dropdown2 otherwise the app should save dropdown1. All of that in order to create a new record in SharePoint.

 

I have the following code:

Patch(Demandes; Defaults(Demandes);{Date_début:DatePicker1.SelectedDate;Date_fin:DatePicker2.SelectedDate; Commentaires:TextInput1.Text; Titre:Label_Employe.Text;If(Dropdown2.Selected="z-Autre";Typec:Dropdown1.Selected;Typec:Dropdown2.Selected)});;Navigate(EcranSortie;ScreenTransition.CoverRight)

 

The error showing is:  Waiting for an operator & or *

 

I dont sure what is the problem, either my IF inside a PATH or IM missing an operator..

 

Anyone have an idea?

 

Thank you so much,

 

2 ACCEPTED SOLUTIONS

Accepted Solutions

Hi @tguihur ,

Note that if not .Value (a Choice field) the xxxxx will be either .Result if a Distinct filter or .FieldName (the actual name of the field filtered), but the syntax below should be correct. If you under the code after you have typed Dropdown1.Selected. (note second dot) you should see the valid values.

 

Patch(
   Demandes; 
   Defaults(Demandes); 
   {
      Date_début:DatePicker1.SelectedDate;
      Date_fin:DatePicker2.SelectedDate; 
      Commentaires:TextInput1.Text;
      Titre:Label_Employe.Text; 
      Typec:
      If(
         Dropdown2.Selected="z-Autre";
         Dropdown1.Selected.xxxxx;
         Dropdown2.Selected.xxxxx
      )
   }
);;
Navigate(
   EcranSortie;
   ScreenTransition.CoverRight
)

 

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

Hi @WarrenBelz 

 

thank you for your answer.

 

I finally figured out like this:

 

Typec:If(Dropdown2.Selected.Colonne1="z-Autre"; Dropdown2.Selected.Colonne1;Dropdown2.Selected.Colonne1)}) ;;

 

Have a good day.

View solution in original post

10 REPLIES 10
Drrickryp
Super User
Super User

Hi @tguihur 

dropdown.selected refers to the control. Dropdown.selected.value refers to the data in the control.

thank for your anwers @Drrickryp   but the same error is still there 😐:

 

Patch(Demandes; Defaults(Demandes);{Date_début:DatePicker1.SelectedDate;Date_fin:DatePicker2.SelectedDate; Commentaires:TextInput1.Text; Titre:Label_Employe.Text;If(Dropdown2.Selected.Value="z-Autre";Typec:Dropdown1.Selected.value;Typec:Dropdown2.Selected.value)});;Navigate(EcranSortie;ScreenTransition.CoverRight)

@tguihur 

Will it work if you capitalize "value" in your formula?

@Drrickryp 

 

Yes, even with Value I got the same error

😕

rvanraamsdonk
Frequent Visitor

Looks to me like your formula is sprinkled with semicolons (;) where comma's should have been used:

 

Patch(Demandes, Defaults(Demandes), {Date_début:DatePicker1.SelectedDate, Date_fin:DatePicker2.SelectedDate, Commentaires:TextInput1.Text, Titre:Label_Employe.Text; If(Dropdown2.Selected="z-Autre", Typec:Dropdown1.Selected, Typec:Dropdown2.Selected)});Navigate(EcranSortie;ScreenTransition.CoverRight)

My PowerApps travail with ;

I believe i am missing a parentheses or anything like that.

Look, the following sentence works very well. It's has ;

 

Patch(Demandes; Defaults(Demandes);{Date_début:DatePicker1.SelectedDate;Date_fin:DatePicker2.SelectedDate; Commentaires:TextInput1.Text; Titre:Label_Employe.Text});;Navigate(EcranSortie;ScreenTransition.CoverRight)

 

But I need to save either my first dropdown or the second one.

 

Any other idea? Thank you.

Apart from the semicolons, I think you need to move the IF statement as follows:

 

Patch(Demandes, Defaults(Demandes), {Date_début:DatePicker1.SelectedDate, Date_fin:DatePicker2.SelectedDate, Commentaires:TextInput1.Text, Titre:Label_Employe.Text; Typec: If(Dropdown2.Selected="z-Autre", Dropdown1.Selected.Value, Dropdown2.Selected.Value)});Navigate(EcranSortie;ScreenTransition.CoverRight)

argument type not valid

 For the following code I got the error : ARGUMENT TYPE NOT VALIDE ,🤔

 

Typec:If(Dropdown2.Selected="z-Autre"; Dropdown2_1.Selected.Value; Dropdown2.Selected.Value)

 

@rvanraamsdonk   THANKS

Hi @tguihur ,

Note that if not .Value (a Choice field) the xxxxx will be either .Result if a Distinct filter or .FieldName (the actual name of the field filtered), but the syntax below should be correct. If you under the code after you have typed Dropdown1.Selected. (note second dot) you should see the valid values.

 

Patch(
   Demandes; 
   Defaults(Demandes); 
   {
      Date_début:DatePicker1.SelectedDate;
      Date_fin:DatePicker2.SelectedDate; 
      Commentaires:TextInput1.Text;
      Titre:Label_Employe.Text; 
      Typec:
      If(
         Dropdown2.Selected="z-Autre";
         Dropdown1.Selected.xxxxx;
         Dropdown2.Selected.xxxxx
      )
   }
);;
Navigate(
   EcranSortie;
   ScreenTransition.CoverRight
)

 

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

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