cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
Super User III
Super User III

@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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

3 REPLIES 3
Super User III
Super User III

@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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

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.

Super User III
Super User III

@ZuzaGlog 

What does your formula look like at this point?

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

Helpful resources

Announcements
secondImage

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

Top Solution Authors
Top Kudoed Authors
Users online (93,687)