You need to sign in to do that
Don't have an account?
sujin h s
action function not calling apex method
Hi All,
Can anyone let me know, why the action function is not calling apex method?
Vf page:
Controller:
My debug statements are not showing in logs & i'm not getting any error.
Thanks!
Can anyone let me know, why the action function is not calling apex method?
Vf page:
<apex:page standardController="Opportunity" extensions="displayAlert"> <apex:form id="eg"> <apex:actionFunction name="Actfun" action="{!UpdatePopupShown}" reRender="eg"> </apex:actionFunction> <script> if('{!Opportunity.Active_Opportunity__c}.checked' && '{!Opportunity.Popup_Shown__c}.unchecked') { console.log("Loaded"); alert("My custom message!"); Actfun(); } </script> </apex:form> </apex:page>
Controller:
public with sharing class displayAlert { ApexPages.StandardController controller; public displayAlert(ApexPages.StandardController controller) { this.controller = controller; } public void UpdatePopupShown() { system.debug('Called controller 1'); Opportunity m = (Opportunity)controller.getRecord(); if(m.Popup_Shown__c == false){ m.Popup_Shown__c = true; system.debug('Called controller 2'); } update m; } }
My debug statements are not showing in logs & i'm not getting any error.
Thanks!
Values from Salesforce database for fields would be returned as true/false.
Try modified script below :
<script>
if('{!Opportunity.Active_Opportunity__c}' == true && '{!Opportunity.Popup_Shown__c}' == false)
{
console.log("Loaded");
alert("My custom message!");
Actfun();
}
</script>
Thanks
Hi Vishwajeet,
<script> is working fine
The action function is not calling "UpdatePopupShown" method from the extension controller(displayAlert).
Yes, i think i got that and it is because it is not able to reach to actionFunction which is called in script, infering from code provided above.
Thanks