cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lolla70
Helper IV
Helper IV

Enable / Disable button based on next day

I have a button that I want to disable once the info submitted and then enable the next day. I wrote this but it is not working

 

DisplayMode:

If(LookUp(

'Back to Work Eligibility',

Employee.Email = VarUserEmail,

'Next Check-In Date'

) < Now(),

DisplayMode.Edit,

DisplayMode.Disabled

)

1 ACCEPTED SOLUTION

Accepted Solutions

Hi@lolla70,

I want to explain to you that the Lookup() function do return the first record of the SP list.

Do you mean that a user could have several records with different Check-in date in a same SP list?

If you want to lookup the latest record for the current user and compare with the Next Check-in date, I think you should try as below.

If(
    First(
        Sort(
            Filter(
                'Back to Work Eligibility',
                Employee.Email = VarUserEmail
            ),
            'Next Check-In Date',
            Descending
        )
    ).'Next Check-In Date' < Now(),
    DisplayMode.Edit,
    DisplayMode.Disabled
)

This is the the day when the current user could edit the button.

First(Sort(Filter('Back to Work Eligibility',Employee.Email=VarUserEmail),'Next Check-In Date',Descending)).'Next Check-In Date'

Hope it could help you.

Regards,

Qi

Best Regards,
Qi

View solution in original post

8 REPLIES 8
LRVinNC
Resident Rockstar
Resident Rockstar

Assuming 'Next Check-In Date' is a date field, try:

If(LookUp('Back to Work Eligibility',Employee.Email = VarUserEmail).'Next Check-In Date'  < Now(),

DisplayMode.Edit, DisplayMode.Disabled)

 

LRVinNC

------------------
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.
v-qiaqi-msft
Community Support
Community Support

Hi@lolla70,

Based on the issue that you mentioned, do you want to disable the button based on the date?

Could you please share a bit more about the scenario, is this 'Next Check-In Date' a Date only type?

I have tested that if it is a Date only type, there will be something error when comparing it with the Now().

You should use the Today() to compare.

Please modify your formula as below:

 

If(LookUp('Back to Work Eligibility',Employee.Email=VarUserEmail,'Next Check-In Date')<Today(),DisplayMode.Edit,DisplayMode.Disabled)

 

Note that 'Next Check-In Date' in my SP list stores the created date so that it will always smaller than the Today() if you validate the button in next day.

Hope it could help.

Regards,

Qi

Best Regards,
Qi

There is no error in the Formula but it didn't work.

Ok

 

I created a list in share point that it includes the Check-In Date and Next Check-In Date. On the App the process goes to click on a button answer some questions once they done, they click confirm and then go back to the main screen. I want the button to be disabled once they go back to the main screen and disable once the next day starts at 12:00AM. Also note that the employee may have a record everyday so the record is not updating. This is the way they want it in my company. Everything is working fine except this button. It work for couple of days with the coding I provide before but then it stopped working.

lolla70_1-1612365026114.png

 

lolla70
Helper IV
Helper IV

I noticed that it is giving me the first record (old Date instead of the new one)

 

lolla70_0-1612389211996.png

 

Hi@lolla70,

I want to explain to you that the Lookup() function do return the first record of the SP list.

Do you mean that a user could have several records with different Check-in date in a same SP list?

If you want to lookup the latest record for the current user and compare with the Next Check-in date, I think you should try as below.

If(
    First(
        Sort(
            Filter(
                'Back to Work Eligibility',
                Employee.Email = VarUserEmail
            ),
            'Next Check-In Date',
            Descending
        )
    ).'Next Check-In Date' < Now(),
    DisplayMode.Edit,
    DisplayMode.Disabled
)

This is the the day when the current user could edit the button.

First(Sort(Filter('Back to Work Eligibility',Employee.Email=VarUserEmail),'Next Check-In Date',Descending)).'Next Check-In Date'

Hope it could help you.

Regards,

Qi

Best Regards,
Qi

Thank you so much. It worked. 

lolla70
Helper IV
Helper IV

Thank you all. 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (3,669)