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
RhooseboyRhooseboy 

Forcing all users to agree to User Agreement on logging in to SF

Hi - my client has asked to have all users be directed to a page when they login to SF where they will be asked to read and agree to a user agreement. The requirement then is to update their user record to show they have read and agreed to the Terms of Use.

 

The critical part is to prevent the user doing anything until they have agreed to the Agreement.

 

Any ideas how to do this?

 

I've looked at adding a homepage component that will use an iframe to reference a VF page and apex class. The VF page and class can first check if they have already said yes to the agreement, and if not, this can then display the Agreement document, capture their agreement with a checkbox, update their user record, and then allow them to carry on and use the system. 

 

Where I'm struggling is stopping the user from using any of the SF pages until they acknowledge. I know I can use CSS to force all of the <a> links to display:none so that will stop the user from doing anything, but I don't see how I can control the CSS of the parent page from within the iframe.

 

Any ideas on how to make this happen - is there an easier solution?

 

 

Best Answer chosen by Admin (Salesforce Developers) 
kamlesh_chauhankamlesh_chauhan

Do not display agreement in iframe itself.

 

(1) Create VF page and write your redirection code in page load. Let us assume it is Page1.

(2) Create another VF page which is for Agreement Page without sidebar and header. Let us assume it is Page2.

(3) In the Page1, check if user is already agreed with the agreement, if yes, do not redirect them to Page2. It will do nothing and user will be able to access all the SF parts normally.

(4) If user is not agreed with the agreement yet, redirect them to the agreement page (Page 2).

 

That way user will be not able to access anything from SF and automatically redirect to Page 2 untill they agreed with the agreement page.

 

Hope this helps.

All Answers

kamlesh_chauhankamlesh_chauhan

Here are the options.

 

(1) Create home page component with VF page in iFrame.

(2) Check if agreed to the Agreement and redirect to the aggreement page (Should be VF page with out header and side bar).

(3) Add similar VF page in Side bar component within iFrame. So if user tries to access anything from SF, it will always check for the agreement and redirect to the agreement page if it is pending.

 

Regards,

Kamlesh

LogicRain Technologies

kamlesh@logicrain.com

www.logicrain.com

RhooseboyRhooseboy

thanks Kamlesh - but how will the Vf page in sidebar component prevent or intercept user from accessing anything from SF - I assume that any CSS here will only affect the iframe, not the parent page?

 

kamlesh_chauhankamlesh_chauhan

Do not display agreement in iframe itself.

 

(1) Create VF page and write your redirection code in page load. Let us assume it is Page1.

(2) Create another VF page which is for Agreement Page without sidebar and header. Let us assume it is Page2.

(3) In the Page1, check if user is already agreed with the agreement, if yes, do not redirect them to Page2. It will do nothing and user will be able to access all the SF parts normally.

(4) If user is not agreed with the agreement yet, redirect them to the agreement page (Page 2).

 

That way user will be not able to access anything from SF and automatically redirect to Page 2 untill they agreed with the agreement page.

 

Hope this helps.

This was selected as the best answer
AmitSahuAmitSahu

Can you use a modal form using JS/Jquery etc ?

 

You can have a object/custom settings to store the value as 1 or 0 for accepted / not accepted.

 

If the vaue is 1 while login show the modal form which will prevent users to click anywhere else.

 

Regards,

 

J

RhooseboyRhooseboy

Many thanks Kamlesh that worked fine.

RhooseboyRhooseboy

Just wondering though why this works fine in the main SFDC environment, but not in a customer portal.

 

In the SFDC environment, the VF page in the IFRAME redirects to the User Agreement page and opens up on top of the parent page outside of the IFRAME.

 

Using the same component in the customer portal, the VF page opens but only within the IFRAME - it does not replace the parent page.

 

 

Any ideas why the difference?

 

Simon.

 

kamlesh_chauhankamlesh_chauhan

What code you are using to redirect to the parent page?

RhooseboyRhooseboy
if (agrees != true) {
    PageReference pageRef = new PageReference('/apex/useragreement');
      return pageRef;
}

 I've read elsewhere that you cannot have a 'target = _top' attribute for a pagereference, and that the way to do this is with oncomplete and javascript from a command button.

 

Simon.

 

kamlesh_chauhankamlesh_chauhan

You need to do it through javascript rather than apex code.

RhooseboyRhooseboy

I ended up getting this to work in the portal by modifying the SiteLoginController apex class  so that the user is directed to  the VF page that tests if they have agreed to the agreement, on a successful login. Seems to work fine.

 

RhooseboyRhooseboy

Got this working in Sandbox - BUT  - it only works with Development Mode turned on.

 

Others testing it didn't get the new VF page, and I figured it was because I had dev mode on and they did not.

 

Came across this posting  - any idea if this is related. Is there some issue with using an IFRAME that it behaves differently in developer mode? I don't really want to set every user us with developer mode!

 

Thanks for your help.