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
john sanjohn san 

Forced User Acceptance Policy Popup - I'm stuck

I'm stuck...trying to coble together code from others here.  Trying to create a page that displays only if a boolean field on the User object is not checked.  Once the user reads/accpts the user acceptance policy the page will not display.  I want this popup to override everything so they cannot bypass it.

 

I added a custom attribute to the user object:  AcceptableUseAgree

I have the following controller:

 

public class popup {

public boolean displayPopup {get; set;}
public boolean AUPok;

public popup() {
ID uID = UserInfo.getUserId();
AUPok = [SELECT AcceptableUseAgree__c FROM User
WHERE Id = :uID].AcceptableUseAgree__c;
}

public void closePopup() {
displayPopup = false;
}

public void showPopup() {
displayPopup = !AUPok;
}
}

 

Here is the page someone else posted.  This page has a button with an action that displays the popup.  However, I want the popup to display if the AcceptableUseAgree__c is false.  How do I do this?

 

<apex:page controller="popup">
<apex:form >

/*
<apex:commandButton value="Show Pop up" action="{!showPopup}" rerender="popup"/>
<apex:pageBlock >
Lorem ipsum ..... dummy stuff to show the popup is above content
</apex:pageBlock>
*/

<apex:outputPanel id="popup">
<apex:outputPanel styleClass="customPopup" layout="block" rendered="{!displayPopUp}">
Lorem ipsum <br/><br/><br/>
<apex:commandButton value="Hide Pop up" action="{!closePopup}" rerender="popup"/>
</apex:outputPanel>
</apex:outputPanel>

</apex:form>

<style type="text/css">
.customPopup{
background-color: white;
border-style: solid;
border-width: 2px;
left: 0%;
padding:10px;
position: absolute;
z-index: 9999;
/* These are the 3 css properties you will need to tweak so the pop
up displays in the center of the screen. First set the width. Then set
margin-left to negative half of what the width is. You can also add
the height property for a fixed size pop up.*/
width: 100%;
margin-left: 0px;
top:0px;
height: 100%
}
</style>
</apex:page>

 

bob_buzzardbob_buzzard

AUPok will be an instance of a user object with just the AcceptableUseAgree__c field populated.  Thus your showpopup should check the value of that field:

 

public void showPopup() {
displayPopup = !AUPok.AcceptableUseAgree__c;
}

 

john sanjohn san

Thanks, Bob.  I've read through the posts on your blog too.  Here is what I have so far...just stuck on the next step.

 

https://www.evernote.com/shard/s19/sh/11e2cdc9-1451-4eae-977f-d25de853bcc1/3ecf53232ad644a765bac79cdd14fbe1