cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ZuzaGlog
Frequent Visitor

Invalid argument type in if statement

Hello community,

I have run into the error while writing an IF statement.

 

What I am trying to achieve:  I want the app to display an error message if the user already submitted his answer for the day, and if the user did not submit the answer today yet, that it patches his choice into the SP list. 

 

The errors: 2 times Invalid argument type. 

 

my statement: 

 

If(ES_l.'Created By' = User().FullName && ES_l.CD = Today(), Notify("You already submitted your answer today", NotificationType.Error), Patch(
    ES_l,
    Defaults(ES_l),
    {
        Title: TitleLabel.Text,
        CD: Today(),
        Date1: Now(),
        Mood1: Smiley.Selected.Value
    }
);
Navigate(ThanksScreen))

 

 where: 

 

ES_l --> SharePoint online list
CD --> Control date (only date/Today())
Date1 --> date with time (Now())
Mood1 --> value 1, 2 or 3 controled by a radio control called Smiley

 

Does anyone know why am I getting these errors? or is there some issue with my logic? 

 

Thank you in advance. 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@ZuzaGlog 

You need to actually lookup your record.  Consider the following formula instead:

If(
    !IsBlank(
        LookUp(ES_l, 
           'Created By'.Email = User().Email && 
           Text(Created, ShortDate) = Text(Today(), ShortDate),
           ID
        )
     ), 

    Notify("You already submitted your answer today", NotificationType.Error), 

    Patch(ES_l, Defaults(ES_l),
        {
        Title: TitleLabel.Text,
        CD: Today(),
        Date1: Now(),
        Mood1: Smiley.Selected.Value
        }
);
Navigate(ThanksScreen))

Note: you don't really need the CD column as SharePoint already has a Created column.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

3 REPLIES 3
RandyHayes
Super User
Super User

@ZuzaGlog 

You need to actually lookup your record.  Consider the following formula instead:

If(
    !IsBlank(
        LookUp(ES_l, 
           'Created By'.Email = User().Email && 
           Text(Created, ShortDate) = Text(Today(), ShortDate),
           ID
        )
     ), 

    Notify("You already submitted your answer today", NotificationType.Error), 

    Patch(ES_l, Defaults(ES_l),
        {
        Title: TitleLabel.Text,
        CD: Today(),
        Date1: Now(),
        Mood1: Smiley.Selected.Value
        }
);
Navigate(ThanksScreen))

Note: you don't really need the CD column as SharePoint already has a Created column.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Hello @RandyHayes ,

Thank you so much for your help.

I was testing the feature in the last days, and it turns out that I only get the error message (even if it is the first submission). Any idea what might be causing it? I tried changing some things around with no luck.

 

Thank you.

RandyHayes
Super User
Super User

@ZuzaGlog 

What does your formula look like at this point?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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