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
sujin h ssujin h s 

Uncaught ReferenceError to action function

Hi all,

I'm trying to display a popup only once based on stage of the opportunity.
So I'm trying to update a field on showing popup once using the below code.
vf page:
<apex:page standardController="Opportunity" extensions="displayAlert">
    <apex:form>
        <apex:outputpanel rendered="{!IF(Opportunity.Status__c='Closed_Won'&& Opportunity.Pop_Up_Shown__c=False,True,False)}"> 
            <script>  
            { 
                console.log("Loaded");
                alert("My custom message!");
                actfun();
            }
            </script> 
        </apex:outputpanel>
        <apex:actionfunction name="actfun" action="{!UpdatePopupShown}"/>
    </apex:form>
</apex:page>
Controller:
public class displayAlert {
    ApexPages.StandardController controller;
    
    public displayAlert (ApexPages.StandardController controller) {
        this.controller = controller;
    }
    
    public void UpdatePopupShown() {
            Opportunity m = (Opportunity)controller.getRecord();
            m.Pop_Up_Shown__c = true;
            update m;
    }
}

On calling actfun() its giving following error:
Uncaught ReferenceError: actfun is not defined

Can anyone let me know what is the issue?
Thanks in advance!

Regards,
Sujin.
 
SwethaSwetha (Salesforce Developers) 
HI Sujin,
Your issue seems similar to https://salesforce.stackexchange.com/questions/145493/uncaught-referenceerror-callaf-is-not-defined. Does it help fix the error in your case ?Thanks
sujin h ssujin h s
Hi Swetha,

This is not working for me! Still the same error.