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
Brian KnowltonBrian Knowlton 

Apex functions not being called from VF page

I have a button on a vf page (using std controller) that when clicked is supposed to call an actionFunction which calls an Apex method. The method does not get called however. I run a javascript method to see if something is happening and it is being clicked, but I cannot get it to call the Apex method. 
function selectProduct()
        {
            console.log('clicked');
            CallApexMethod();
         	console.log('Complete');
        }


<apex:form id="searchProducts">
    	<apex:actionFunction name="CallApexMethod" action="{!myActionInController}" onComplete="alert('After apex method') ;"/>
        <apex:outputPanel id="main">
...


<div class="selectButton">
                <input type="button" value="Select" onclick="selectProduct();"/>
</div>

 
KevinPKevinP
Brian,

Try using a command button, with an value of "{!selectProduct}"

Otherwise, call the name of the apex:Actionfunction that you delcared rather than the method in your controller. ie: onclick="callApexMethod"
Brian KnowltonBrian Knowlton
When I try to use onclick="{!searchProducts}" it throws an error:
Save error: Unknown property 'OpportunityStandardController.searchProducts'    opportunityProductEntry.page
KevinPKevinP
Brian,

again, try using an apex:commandButton

or use the name of the apex:actionFunction that you declared on line 10. ie: "CallApexMethod" not searchproducts. 
Brian KnowltonBrian Knowlton
Sorry I just read that last part again. I have tried that as well, but no luck
 
Brian KnowltonBrian Knowlton
I've also tried commandButton as well
Brian KnowltonBrian Knowlton
Have you come accross where something in the constructor prevents code from working?
Brian KnowltonBrian Knowlton
found the issue...a list that I was generating was supposed to be transient, because it was constantly changing. Thanks for the help!