cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
akbarmahfuzalam
Post Prodigy
Post Prodigy

Button DisplayMode Logic with Date and Time Variable

Hi Team,

 

I am stuck while creating an App for the test paper. Wherein I am asking the app 2 conditions.

 

1. To visible only if the user is not attempted a test

2. Only visible wherein I have defined the Variable in the form of an input Text as DateLimitation.Text if it matches then only it's visible or not visible.

Example: If I defined the date of 15 days, the Powerapps should check the Sharepoint list date for that user and act accordingly.  If it does not find any email and date combination, it should allow the user to click the button or else greyed out for him/her. Since they have given the test within the time span of 15 days. If not allowed them to click the button.

 

Set(
UserLastTestDay,
DateDiff(
DateValue(
Last(
Sort(
Filter(
PKTDemo,
'Created By'.Email = VarUser.currentUserEmail
),
ID,
Ascending
)
).PKTDate
),
Today(),
Days
)
);
Set(
NextDateTest,
DateAdd(
DateValue(
Last(
Sort(
Filter(
PKTDemo,
'Created By'.Email = VarUser.currentUserEmail
),
ID,
Ascending
)
).PKTDate
),
Value(DateLimitation.Text)
)
);
Set(
UserLastTestDate,
DateValue(
Last(
Sort(
Filter(
PKTDemo,
'Created By'.Email = VarUser.currentUserEmail
),
ID,
Ascending
)
).PKTDate
)
);

 

So have created 3 collections onStart and the first one is not working for me. Error: incorrect argument type, expected a number

Set(
UserLastTestDay,
DateDiff(
DateValue(
Last(
Sort(
Filter(
PKTDemo,
'Created By'.Email = VarUser.currentUserEmail
),
ID,
Ascending
)
).PKTDate
),
Today(),
Days
)
);

 

So on the button displayMode = If(Today()<UserLastTestDay,DisplayMode.Edit,UserLastTestDay<=Value(DateLimitation.Text),DisplayMode.Disabled)

akbarmahfuzalam_0-1616549835050.pngakbarmahfuzalam_1-1616549869988.png

 



15 REPLIES 15

Hi @akbarmahfuzalam ,

 

If I understand correctly, do you mean that after selecting a date which is the next test date, if today is equal to or later than it, the button is clickable?

 

If so, why not simply emulate today with the selected date?

 

If(IsBlank(UserLastTestDate) || Today()>= DateLimitation.SelectedDate,DisplayMode.Edit,DisplayMode.Disabled)

 

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

@v-jefferni 

 

The button needs to be grayed out but is not. Ideally, it allows the user to give the button as clickable by 28th March 2021.

 

akbarmahfuzalam_1-1616575139360.png

 

akbarmahfuzalam_0-1616575019935.png

 

Hi @akbarmahfuzalam ,

 

Sorry, I have modified my last post. Please have a try.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

@v-jefferni 

 

When I don't have an entry in SharePoint and I am new to give a test, I get the below error, but am able to see the button as clickable.

 

akbarmahfuzalam_0-1616578849177.png

 

Hi @akbarmahfuzalam ,

 

If you select the date limitation in a Date Picker, you will only need the variable UserLastTestDate OnStart of the App. 

 

You have made the scenario too complicated. In a nutshell:

1\ OnStart of the App:

Set(UserLastTestDate,DateValue(Last(Sort(Filter(PKTDemo,'Created By'.Email=VarUser.currentUserEmail),ID,Ascending)).PKTDate))

 

2\ DisplayMode of the Button:

If(IsBlank(UserLastTestDate) || Today()>= DateLimitation.SelectedDate,DisplayMode.Edit,DisplayMode.Disabled)

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

akbarmahfuzalam
Post Prodigy
Post Prodigy

@v-jefferni 

 

Sorry to bother you again. I just realized that on my home screen whenever I am changing the number which corresponds to the Date value. It's not running. Every time I need to press on Run OnStart. 

akbarmahfuzalam_0-1617178165800.png

I want the moment I change the Number from 15 to any x y z number it change the Date accordingly, which I need to press Run OnStart every time .




Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,258)