cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Prodigy
Post Prodigy

if function help please

Hi,

I need some help with the code for my next button please.

I want to restrict navigation at this statge to only 5 approvers, 2 admins and the applicant
If the logged in user (VarUser) is not named in a 5 approver fields, they should be prompted with a message stating you are not an approver, I thought this may work for just 1 user:

If(!DataCardValue81.Selected.Email = VarUser , Notify("You cannot proceed as you are not an approver", NotificationType.Error))

As soon as I had ! under the = sign it states I'm using incompatible type

I'll need help adding the above suggestion (when someone can help me fix it) inside an already long if function on my Next buttons OnSelect:

If(VarUser = DataCardValue81.Selected.Email, Navigate(Screen1, Fade),
If(VarUser = DataCardValue65.Selected.Email, Navigate(Screen2, Fade),
If(VarUser = DataCardValue64.Selected.Email, Navigate(Screen3, Fade),
If(VarUser = DataCardValue68.Selected.Email, Navigate(Screen4, Fade),
If(VarUser = DataCardValue69.Selected.Email, Navigate(Screen5, Fade),
If(And(VarUser = "email1.uk" || VarUser = DataCardValue90_1.Selected.Email || VarUser = "email2.uk"), 
If(!IsBlank(DataCardValue81.Selected.Email), Navigate(Screen1,Fade),
If(!IsBlank(DataCardValue65.Selected.Email), Navigate(Screen2, Fade),
If(!IsBlank(DataCardValue64.Selected.Email), Navigate(Screen3, Fade),
If(!IsBlank(DataCardValue68.Selected.Email), Navigate(Screen4, Fade),
If(!IsBlank(DataCardValue69.Selected.Email), Navigate(Screen5, Fade),
Notify("No approvers have been added", NotificationType.Error)

)))))))))))

 

Thanks 

15 REPLIES 15
Highlighted

I'm not sure if this helps you, but you can always use several functions after each other.

you have only to seperate them with a ";"

 

For example:

Notify("this message",NotificationType.Error);If(TextInput1.text = "",Notify("Text is blank",NotificationType.Error))

 

Highlighted
Community Support
Community Support

Hi @G99 ,

 

Please modify your formula as below:

If(
    !IsBlank(DataCardValue81.Selected.Email) || !IsBlank(DataCardValue65.Selected.Email) || !IsBlank(DataCardValue64.Selected.Email) || !IsBlank(DataCardValue68.Selected.Email) || !IsBlank(DataCardValue69.Selected.Email),
    If(
         VarUser = DataCardValue81.Selected.Email || VarUser = DataCardValue65.Selected.Email || VarUser = DataCardValue64.Selected.Email || VarUser = DataCardValue68.Selected.Email || VarUser = DataCardValue69.Selected.Email || VarUser = "email1.uk" || VarUser = DataCardValue90_1.Selected.Email || VarUser = "email2.uk",
         Navigate(
                  If(
                     VarUser = DataCardValue81.Selected.Email, Screen1,
                     VarUser = DataCardValue65.Selected.Email, Screen2,
                     VarUser = DataCardValue64.Selected.Email, Screen3,
                     VarUser = DataCardValue68.Selected.Email, Screen4,
                     VarUser = DataCardValue69.Selected.Email, Screen5
                  )
         ),
         Notify("Send Statenment here....", NotificationType.Error)
      ),
      // Np approver have been added
      Notify("No approvers have been added", NotificationType.Error)
)

 

Please take a try with above solution, check if the issue is solved.

 

Best regards,

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

@v-xida-msft 

I've tried this also

nothing happens when I click next, i.e. no message appears at all if I do not enter my own email as one of the approvers.

As soon as I put my username in DataCardValue81 It allows me to navigate to that, but if I put a test account in there, it should have allowed me to navigate to that screen also as I have hardcoded my email in the 2ndif statement.

 

 

Highlighted
Community Support
Community Support

Hi @G99 ,

I assume that the "

VarUser = "email1.uk" || VarUser = DataCardValue90_1.Selected.Email || VarUser = "email2.uk"

" condition is used to check if the current login in user is an admin, is it right?

 

Please consider take a try with the following formula within the "Next" button OnSelect property:

If(
   VarUser = "email1.uk" || VarUser = DataCardValue90_1.Selected.Email || VarUser = "email2.uk",
   If(
      !IsBlank(DataCardValue81.Selected.Email), Navigate(Screen1,Fade),
      !IsBlank(DataCardValue65.Selected.Email), Navigate(Screen2, Fade),
      !IsBlank(DataCardValue64.Selected.Email), Navigate(Screen3, Fade),
      !IsBlank(DataCardValue68.Selected.Email), Navigate(Screen4, Fade),
      !IsBlank(DataCardValue69.Selected.Email), Navigate(Screen5, Fade),
      Notify("No approvers have been added", NotificationType.Error)
   ),
   If(
      !IsBlank(DataCardValue81.Selected.Email) || !IsBlank(DataCardValue65.Selected.Email) || !IsBlank(DataCardValue64.Selected.Email) || !IsBlank(DataCardValue68.Selected.Email) || !IsBlank(DataCardValue69.Selected.Email),
      If(
          VarUser = DataCardValue81.Selected.Email, Navigate(Screen1),
          VarUser = DataCardValue65.Selected.Email, Navigate(Screen2),
          VarUser = DataCardValue64.Selected.Email, Navigate(Screen3),
          VarUser = DataCardValue68.Selected.Email, Navigate(Screen4),
          VarUser = DataCardValue69.Selected.Email, Navigate(Screen5),
          Notify("Second Statement shows up here......", NotificationType.Error)
      )
   )
)

check if the above formula could fix your issue.

 

Best regards,

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

HI @v-xida-msft 

 

Thanks I've implemented this and now if I have no approvers entered I get the message appear No approvers added - So that works

As the admin I can navigate to the next active screen - So that works

 

But a user has reported, even though he is a named approver in DataCardValue81 he receives the notification appear you are not an approver...: and cannot navigate to Screen1

If(
   VarUser = "Admin1email" || VarUser = DataCardValue90_1.Selected.Email || VarUser = "Admin2Email",
   If(
      !IsBlank(DataCardValue81.Selected.Email), Navigate(Screen1,Fade),
      !IsBlank(DataCardValue65.Selected.Email), Navigate(Screen2, Fade),
      !IsBlank(DataCardValue64.Selected.Email), Navigate(Screen3, Fade),
      !IsBlank(DataCardValue68.Selected.Email), Navigate(Screen4, Fade),
      !IsBlank(DataCardValue69.Selected.Email), Navigate(Screen5, Fade),
      !IsBlank(DataCardValue79.Selected.Email), Navigate(Screen6, Fade),
      !IsBlank(DataCardValue80.Selected.Email), Navigate(Screen7, Fade),
      !IsBlank(ComboBox1.Selected.Email), Navigate(Screen8, Fade),
      Notify("No approvers have been added", NotificationType.Error)
   ),
   If(
      !IsBlank(DataCardValue81.Selected.Email) || !IsBlank(DataCardValue65.Selected.Email) || !IsBlank(DataCardValue64.Selected.Email) || !IsBlank(DataCardValue68.Selected.Email) || !IsBlank(DataCardValue69.Selected.Email) || !IsBlank(DataCardValue79.Selected.Email) || !IsBlank(DataCardValue80.Selected.Email) || !IsBlank(ComboBox1.Selected.Email),
      If(
          Lower(VarUser) = DataCardValue81.Selected.Email, Navigate(Screen1),
          Lower(VarUser) = DataCardValue65.Selected.Email, Navigate(Screen2),
          Lower(VarUser) = DataCardValue64.Selected.Email, Navigate(Screen3),
          Lower(VarUser) = DataCardValue68.Selected.Email, Navigate(Screen4),
          Lower(VarUser) = DataCardValue69.Selected.Email, Navigate(Screen5),
          Lower(VarUser) = DataCardValue79.Selected.Email, Navigate(Screen6),
          Lower(VarUser) = DataCardValue80.Selected.Email, Navigate(Screen7),
          Lower(VarUser) = ComboBox1.Selected.Email, Navigate(Screen8),
          Notify("You are not an approver......", NotificationType.Error)
      )
   )
)

 

Highlighted
Community Support
Community Support

Hi @G99 ,

Based on the issue that you mentioned, I think this issue may be related to "

Lower(VarUser) = DataCardValue81.Selected.Email

" formula in your nested If formula.

 

Please make sure the result the Lower(VarUser) formula returned could match the result the DataCardValue81.Selected.Email formula returned.

Please modify your formula as below:

If(
   VarUser = "Admin1email" || VarUser = DataCardValue90_1.Selected.Email || VarUser = "Admin2Email",
   If(
      !IsBlank(DataCardValue81.Selected.Email), Navigate(Screen1,Fade),
      !IsBlank(DataCardValue65.Selected.Email), Navigate(Screen2, Fade),
      !IsBlank(DataCardValue64.Selected.Email), Navigate(Screen3, Fade),
      !IsBlank(DataCardValue68.Selected.Email), Navigate(Screen4, Fade),
      !IsBlank(DataCardValue69.Selected.Email), Navigate(Screen5, Fade),
      !IsBlank(DataCardValue79.Selected.Email), Navigate(Screen6, Fade),
      !IsBlank(DataCardValue80.Selected.Email), Navigate(Screen7, Fade),
      !IsBlank(ComboBox1.Selected.Email), Navigate(Screen8, Fade),
      Notify("No approvers have been added", NotificationType.Error)
   ),
   If(
      !IsBlank(DataCardValue81.Selected.Email) || !IsBlank(DataCardValue65.Selected.Email) || !IsBlank(DataCardValue64.Selected.Email) || !IsBlank(DataCardValue68.Selected.Email) || !IsBlank(DataCardValue69.Selected.Email) || !IsBlank(DataCardValue79.Selected.Email) || !IsBlank(DataCardValue80.Selected.Email) || !IsBlank(ComboBox1.Selected.Email),
      If(
          Lower(VarUser) = Lower(DataCardValue81.Selected.Email), Navigate(Screen1),  // Modify formula here
          Lower(VarUser) = Lower(DataCardValue65.Selected.Email), Navigate(Screen2), // Modify formula here
          Lower(VarUser) = Lower(DataCardValue64.Selected.Email), Navigate(Screen3), // Modify formula here
          Lower(VarUser) = Lower(DataCardValue68.Selected.Email), Navigate(Screen4), // Modify formula here
          Lower(VarUser) = Lower(DataCardValue69.Selected.Email), Navigate(Screen5), // Modify formula here
          Lower(VarUser) = Lower(DataCardValue79.Selected.Email), Navigate(Screen6), // Modify formula here
          Lower(VarUser) = Lower(DataCardValue80.Selected.Email), Navigate(Screen7), // Modify formula here
          Lower(VarUser) = Lower(ComboBox1.Selected.Email), Navigate(Screen8), // Modify formula here
          Notify("You are not an approver......", NotificationType.Error)
      )
   )
)

Please apply Lower() function to the DataCardValue81.Selected.Email, DataCardValue65.Selected.Email, DataCardValue64.Selected.Email, .... formulas as well.

Note: I assume that you could only select single one option within DataCardValue81, DataCardValue65, DataCardValue64, ....

 

Please make sure the VarUser variable store the email address of the current login in user in your app properly. You could consider replace it with User().Email in your above formula directly.

 

Please take a try with above solution, then check if the issue is solved.

 

Best regards,

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

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (10,198)