function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
A guestA guest 

Restrict users login only for an hour

Hi guyz,

I want  to restrict the users login to the salesforce for one particular time slot. eg. user should not be able login between 5.30  pm to 6.30 pm every day.
in all other timings he should be able to login to the salesforce instance.
How can i achieve this, it would be great if anyone help me to achieve this

Thanks
Best Answer chosen by A guest
MariuszMariusz
if I understand your case correctly, then the solution below should work:

1. Create a checkbox that will track the history of whether the Proposal Submitted Stage was saved at least once (default value - false)
2. Create a workflow rule or process that changes the checkbox to true after user save the Opportunity in Proposal Submitted stage.
3. Create a validation rule following the example below (api name is a name of the stage beyond Proposal Submitted):

AND( 
 Proposal_was_submitted__c = FALSE, 

 OR( 
  TEXT(StageName) = "api name 1", 
  TEXT(StageName) = "api name 2", 
  TEXT(StageName) = "api name 3", 
 ) 
)

All Answers

MariuszMariusz
You can set login hours quite easily by using profiles. 
Step by step guide is here
https://help.salesforce.com/articleView?id=users_profiles_epui_login_hours_edit.htm&type=5
and here
https://help.salesforce.com/articleView?id=login_hours.htm&type=5
(depends on the profile user interface)
A guestA guest
Hi Mariusz thanks for your Reply,

I tried with the link which u have provided there we can enable login hours for a particular profile eg. user login hours between 9 AM to 6 PM.
But i wanted to restrict only for an hour in a day eg. user should not be able to login only from  2 AM to 3 AM or 7.30 PM to 8.30 PM , all other time he must be able to login.
MariuszMariusz
Ok, now I see I didn't give you a full answer, sorry for that.

I think that you can do it by changing the Default Time Zone on the Company Information page and trying to fit it so that the period in which users can log in is uninterrupted.

e.g. your time zone is GMT +00:00 and users should not be able to login from 5AM to 6AM. So you can change your default time zone to GMT -05:00, set the start time to 1AM and the end time to EoD, and than return to your previous Default Time Zone. 

According to this note, everything should work just fine:
"The first time login hours are set for a profile, the hours are based on the organization’s Default Time Zone as specified on the Company Information page in Setup. After that, any changes to the organization’s Default Time Zone won’t change the time zone for the profile’s login hours. As a result, the login hours are always applied at those exact times even if a user is in a different time zone or if the organization’s default time zone is changed."
A guestA guest
Thanks for your quick response i will try this solution.
A guestA guest
I have one more use case,

User should not be able to select a stage beyond Proposal Submitted until user saves the opportunity in this stage once. 
User shouldn't be able to directly set a stage beyond 'Proposal Submitted' as this is the 4th stage in total 7 stages of opportunity pipeline.How can I do this.

Thanks for your support.
MariuszMariusz
if I understand your case correctly, then the solution below should work:

1. Create a checkbox that will track the history of whether the Proposal Submitted Stage was saved at least once (default value - false)
2. Create a workflow rule or process that changes the checkbox to true after user save the Opportunity in Proposal Submitted stage.
3. Create a validation rule following the example below (api name is a name of the stage beyond Proposal Submitted):

AND( 
 Proposal_was_submitted__c = FALSE, 

 OR( 
  TEXT(StageName) = "api name 1", 
  TEXT(StageName) = "api name 2", 
  TEXT(StageName) = "api name 3", 
 ) 
)
This was selected as the best answer
A guestA guest
Wow great !
cool solution worked for me thanks