You need to sign in to do that
Don't have an account?

Turn off Pop Up Alert
I'm trying to do a popup alert that just lets people know that a record has been created when they do a certain action. It's kind of an FYI thing. So I tried a VF page embedded in the Opp layout and that worked but it showed up everytime they went to the record once it met the criteria. So then I tried adding a controller to the page that would check a box saying that the alert was shown. The controller works and checks the box but now the popup doesn't show. Is there any way to get BOTH of these working as one solution?
Thanks so much!
Amanda
Here's the first VF page I tried which works to show the popup:
<apex:page standardcontroller="Opportunity" rendered="{!Opportunity.stagename=='Commitment' && Opportunity.Opportunity_Rolled__c==True && Opportunity.Alert_Shown__c==False}" >
<script type="text/javascript">
{
window.alert("This Opportunity has Been Rolled to the next applicable Semester");
}
</script>
</apex:page>
And here's the second one I tried that will check the box but not actually show the alert.
<apex:page standardController="Opportunity" action="{!markread}" extensions="CloneAlertExtension">
<script type="text/javascript">
if({!Opportunity.stagename=='Commitment' && Opportunity.Opportunity_Rolled__c==True && Opportunity.Alert_Shown__c==False}) {
window.alert("This Opportunity has Been Rolled to the next applicable Semester");
}
</script>
</apex:page>
public with sharing class CloneAlertExtension {
ApexPages.StandardController controller;
public CloneAlertExtension(ApexPages.StandardController controller) {
this.controller = controller;
}
public void markread() {
Opportunity o = (Opportunity)controller.getRecord();
o.Alert_Shown__c = true;
update o;
}
}
Thanks so much!
Amanda
Here's the first VF page I tried which works to show the popup:
<apex:page standardcontroller="Opportunity" rendered="{!Opportunity.stagename=='Commitment' && Opportunity.Opportunity_Rolled__c==True && Opportunity.Alert_Shown__c==False}" >
<script type="text/javascript">
{
window.alert("This Opportunity has Been Rolled to the next applicable Semester");
}
</script>
</apex:page>
And here's the second one I tried that will check the box but not actually show the alert.
<apex:page standardController="Opportunity" action="{!markread}" extensions="CloneAlertExtension">
<script type="text/javascript">
if({!Opportunity.stagename=='Commitment' && Opportunity.Opportunity_Rolled__c==True && Opportunity.Alert_Shown__c==False}) {
window.alert("This Opportunity has Been Rolled to the next applicable Semester");
}
</script>
</apex:page>
public with sharing class CloneAlertExtension {
ApexPages.StandardController controller;
public CloneAlertExtension(ApexPages.StandardController controller) {
this.controller = controller;
}
public void markread() {
Opportunity o = (Opportunity)controller.getRecord();
o.Alert_Shown__c = true;
update o;
}
}
All Answers
Action method is called before the page is rendered, after the constructor, so your flag is already true by the time your script executes.
You should try to call your action-method using ActionScript after your alert javascript
<apex:page standardcontroller="Opportunity" rendered="{!Opportunity.stagename=='Commitment' && Opportunity.Opportunity_Rolled__c==True && Opportunity.Alert_Shown__c==False}" >
<script type="text/javascript">
{
window.alert("This Opportunity has Been Rolled to the next applicable Semester");
}
</script>
</apex:page>
Is the only one that I can get to show the popup itself. I found a few examples of people calling action methods on buttons and such but as soon as I try adding my extension into this code it stops working. And if I take out the action code of the second one that I had it still doesn't show the popup. Could you give me a more specific example of what you meant by using ActionScript after my alert javascript? As you can probably tell I'm pretty new to Javascript.
Thanks so much,
Amanda
So the result would be, that markread would be called after the alert has displayed.
Hope you get the idea.
Error: Unknown property 'OpportunityStandardController.markread'
I tried changing my controller class to the below code but it still keeps saying unknown property
public class CloneAlertExtension {
Public Opportunity opportunity {get;set;}
public CloneAlertExtension(ApexPages.StandardController controller) {
this.opportunity = (Opportunity) controller.getRecord();
opportunity = [Select Id, Name, AccountId, Alert_Shown__c
From Opportunity
Where Id =: opportunity.id];
}
public void markread() {
Opportunity o = this.opportunity;
o.Alert_Shown__c = true;
update o;
}
}