Friday, April 12, 2013

Display a Popup when a User Login to Salesforce




Many times there is a need to broadcast a message to all the SFDC users whenever they log into the org, the message could be just a Reminder/Policy changes
or sometimes user needs to accept the terms & condn to use a particular application.
So when the user logs into the org and the first thing he/she sees is a pop up screen. He can neglect the message and continue working on his tasks but This
message needs to be displayed every time user logs in till the USer Accepts the information.

e.g. Lets say you have launched a new app in your sfdc org and you want to display the app usage policy to all the users before they can start using the
app. i.e. you want the Users to accept the policies.

In order to build this the following steps can be implemented in your SFDC org:

1) Develop a VF page which will display a popup to the end user: Something like this http://www.salesforcegeneral.com/salesforce-modal-dialog-box/

2) You will need a corresponding apex class too to support the VF page.

3) In order to check whether the User has accepted the policy or not; lets add a checkbox field on the User records... lets say Policy Accepted

4) In our controller class we can use UserInfo method to get the current user details and check whether this flag is checked or not.
If the flag is checked then we'll redirect the user to the std Home page if its unchecked we'll display the popup to the User. The pouup will have Accept
Button, if user clicks this button the Policy accepted flag on the User record will be set to true.

Final & the most important Trick :)

5) Create a VF custom TAB and overwrite this TAB with the VF page we created above.
6) Add this TAB as a default landing TAB in all of your Apps and you are done!!

Let me know if you need more explanation....I hope this post will be helpful to many salesforce developers.

- Rahul