cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sumeetrajan
Helper I
Helper I

Button visible only one time/day

Hi,

 

I have developed an tool to capture log in & log out time

logic - whenever user clicks on log in button, using patch function i create a new a line in SharePoint list.

 

Need a way to not allow users to click "log in" button twice/day.

 

Note -SP list would contact log in time for multiple days.

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
zaphod88
Responsive Resident
Responsive Resident

One way I'd think of to get around the delegation issue is to load a filtered collection OnStart/OnVisible like:
ClearCollect(CollToday, Filter(SPList, Date = Today(), Title = varUserDisplayName))
and to check if it's empty in your buttons DisplayMode
If(IsEmpty(CollToday), Edit, Disabled)
AFAIK, the Filter() should be delegable.

View solution in original post

5 REPLIES 5
v-qiaqi-msft
Community Support
Community Support

Hi @sumeetrajan,

Based on the issue that you mentioned, do you want to create only one record for Today?

Could you please share a bit more about the scenario?

Not sure how you write the Patch() function once user clicks on the login button, I just make a similar test for you, please check as below.

My solution is very easy, just check the SP list for that if there is an existing records created Today, if there is, then disable the button, otherwise, enable the button.

Set the DisplayMode property of the log in button as below:

 

If(CountRows(Filter(SPList,Created=Today()))>=1,Disabled,Edit)

Note that the login button would be able to click only when there is no record created Today.

Or set the Visible property of the log in button as below:

If(CountRows(Filter(SPList,Created=Today()))>=1,false,true)​

 

Check if it could help.

Regards,

Qi

 

Hi,

 

Countrows is not an delegable functions, my SPlist would be contacts more than 10,000 rows. so its not an feasible options.

sumeetrajan_0-1620380903421.png

any alternate logic.

 

Patch function

Patch(
'SPlist',
Defaults('SPlist'),
{Title: varUserDisplayName,
'Log in': Text(Now(),DateTimeFormat.ShortDateTime)}

Hi @sumeetrajan,

Do you want to make the login button disabled once it it clicked?

If so, I think a variable could achieve your needs.

Set the OnSelect property of the login button as below:

Set(vari,1);
Patch(
'SPlist',
Defaults('SPlist'),
{Title: varUserDisplayName,
'Log in': Text(Now(),DateTimeFormat.ShortDateTime)} // Just paste your Patch() formula here

Set the DisplayMode property of the login button as below:

If(IsBlank(vari),Edit,Disabled)

Hope it could help.

Regards,

Qi

Hi,

 

Sorry, the problem with variable is the data stored is temporary, the values becomes 0 when we close the app & whenever the user will reopen the app. the log in button would be visible. 

let me know if you agree to what i have just said

zaphod88
Responsive Resident
Responsive Resident

One way I'd think of to get around the delegation issue is to load a filtered collection OnStart/OnVisible like:
ClearCollect(CollToday, Filter(SPList, Date = Today(), Title = varUserDisplayName))
and to check if it's empty in your buttons DisplayMode
If(IsEmpty(CollToday), Edit, Disabled)
AFAIK, the Filter() should be delegable.

View solution in original post

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 is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (12,611)