web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / disable button based o...
Power Apps
Unanswered

disable button based on multiple user conditions in sharepoint list

(0) ShareShare
ReportReport
Posted on by 130

Hello all,

 

I have a sharepoint list with userid, username, createddate columns.

User will fill have option to fill survey each day, if he tries to fill survey multiple times in a day, fill survey button should be disabled.

 

I tried below on OnSelect of fill survey button:

If(CountRows(Filter(UserReport, DateDiff(CreatedDate, Now(), Days)=0))>0, Notify("Survey already submitted", NotificationType.Error, 1000), Navigate(SurveyQuestions);

 

The above is working for date part, but not able to check for the user. It just disabled for all users based on todays date.

 

Any idea how it can be done. Many thanks.

Categories:
I have the same question (0)
  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    You need to add in a check for the user.   Are you already getting the user information using the Office365users connector?

     

    If not, try setting a variable in the App start section:   Set(varUser, Office365Users.MyProfileV2().displayName

     

    Then validate that against the created by in the list.   To disable the button you may want set a variable in the OnSelect based on your criteria and then use that variable in the Button DisplayMode property.

     

    in your app start set your visibility variable to true:  Set(varSurveyButtonVisible, true)

     

    In the submit button display mode property:  If(varSurveyButtonVisible,   DisplayMode.Edit, DisplayMode.Disabled)

    When the variable is set to false based on your criteria in the onSelect, the button becomes disabled.

  • CU-18081211-6 Profile Picture
    9,270 Moderator on at

    Hi @TheOpeningBat ,

     

    You can filter UserReport list also on user who created the record: (before create a context or global variable to avoid delegation warning to keep the User().Mail - UpdateContext({currentUserEmail:User().Email})

     

     If(CountRows(Filter(UserReport, DateDiff(CreatedDate, Now(), Days)=0 && Author.Email = currentUserEmail ))>0, Notify("Survey already submitted", NotificationType.Error, 1000), Navigate(SurveyQuestions);

     

    Isn't much easier if you prevent this by disabling the button if the user already take the survey on the current day. I mean to set DisplayMode property of the button to:

     If(CountRows(Filter(UserReport, DateDiff(CreatedDate, Now(), Days)=0 && Author.Email = currentUserEmail ))>0,DisplayMode.Disabled, DisplayMode.Edit)

     

    Is a bad user experience to receive a NotificationError (no matter what!), so I think it better to avoid this.

     

    Hope it helps ! 

  • TheOpeningBat Profile Picture
    130 on at

    Hi @gabibalaban ,

     

    I tried the below on the DisplayMode Property of button but it says function countrows has some invalid arguments.

     

     If(CountRows(Filter(UserReport, DateDiff(CreatedDate, Now(), Days)=0) && UserReport.Email = currentUserEmail)>0,DisplayMode.Disabled, DisplayMode.Edit)

    Could you tell if I am missing something?

  • CU-18081211-6 Profile Picture
    9,270 Moderator on at

    @TheOpeningBat 

    Please use Author instead of UserReport, as I wrote it in my formula.

  • TheOpeningBat Profile Picture
    130 on at

    @gabibalaban Still it’s giving the same error. 
    sorry I’m not aware about Author. Actually I need to check from the Sharepoint list whether user has taken the survey

  • CU-18081211-6 Profile Picture
    9,270 Moderator on at

    I look on your formula again and don't seems to look like mine... please put the paranthesis on the same place 

  • TheOpeningBat Profile Picture
    130 on at

    Hi @gabibalaban ,

    Sorry my bad, on mobile might be I was not able to see properly. Was able to find the missing parenthesis on desktop.

     

    However even if the user has taken the survey today, survey button is not disabled.

     

    Also on the take survey button - where should i add Navigate(SurveyQuesitons)? OnSelect of the button or else where?

  • TheOpeningBat Profile Picture
    130 on at

    Hi @gabibalaban . If I don't use Author.Email & just use Email then it is working fine. Is that the correct way?

     

    If that is fine then I can mark your answer as solution. Please let me know.

  • Verified answer
    CU-18081211-6 Profile Picture
    9,270 Moderator on at

    @TheOpeningBat It's a little bit strange that it works only with Email and not with Author.Email, and I have my doubts that is works fine (it means that you have a column called Email in your sharepoint list).

    About the delagation warning that you receive, this came from this part of the formula: 

     DateDiff(CreatedDate, Now(), Days)=0) because the DateDiff function is not delegable to Sharepoint.

    To avoid it, you can use this kind of formula:

    Created>Today() &&Created<=DateAdd(Today(),1,Days))

     

    So, my final proposal 😊 for your formula is:

     If(CountRows(Filter(UserReport,  Created>=Today() && Created<DateAdd(Today(),1,Days) && Author.Email = currentUserEmail))>0,DisplayMode.Disabled, DisplayMode.Edit)

     

     

  • TheOpeningBat Profile Picture
    130 on at

    yes @gabibalaban, I have a column named Email in my sharepoint list.

    Also with your changes, the delegate warning is not appearing.

     

    Thanks a lot again for your help. Will mark your last reply as the solution.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard