I have a requirement to display a popup message ONLY when the opp is created and it satisfies a condition (for instance, amount >100000). Im stuck here at the implementation of the javascript and how to invoke from apex:
Finally, got this to work:
VF page:
<apex:page standardController="opportunity" extensions="oppMessage" >
<apex:form >
<apex:actionFunction action="{!markread}" name="markread"/>
</apex:form>
<script>
if ({!Opportunity.Amount}>10000 && {!!Opportunity.messageshown__c}) {
alert ("Contact Mr. X");
markread ();
}
</script>
</apex:page>
Controller:
public class oppMessage {
ApexPages.StandardController controller;
public oppMessage(ApexPages.StandardController controller) {
this.controller = controller;
}
public void markread() {
Opportunity o = (Opportunity)controller.getRecord();
o.MessageShown__c = true;
update o;
}
}
messageshowncustom field is false then display the message and set the fieldmessageshowncustom field to true . – javanoob May 22 '17 at 14:38messageShownand make sure that default value for this field is false. With this every time a opportunity is created, the fieldmessageShown__cwill be false by default. In the inline vf page, check ifmessageShown__cis false and satisfies your crtieria(opp amount > 10000) then display alert and set the fieldmessageShown__cto true. If the same opp is opened again 'messageShown__c' field will be true and don't show the pop up. – javanoob May 22 '17 at 14:46