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 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 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

View solution in original post

3 REPLIES 3
RandyHayes
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 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

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 III
Super User III

@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

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (3,073)