You need to sign in to do that
Don't have an account?
Kyle Buzza
Visualforce actionFunction not working
I have a VF page that inserts a related event using a custom controller extension. I'm trying to call another controller function that will return the created event Id. I'm testing the function using an alert, but for some reason it just alerts "false" and not the event Id.
<apex:page id="pg" standardController="Contact" extensions="JoinMeContactController"> <script> function openPage (){ alert(GettingEvent()); var win = window.open('https://www.join.me', '_blank'); win.focus(); } </script> <apex:form > <apex:actionFunction name="GettingEvent" action="{! getEvent}" /> <apex:commandbutton image="{!URLFOR($Resource.JoinMeLogo)}" style="width:125px; height:125px; background:black; margin:0" onClick="openPage()" action="{! newEvent}"/> </apex:form> </apex:page>
public with sharing class JoinMeContactController { public Contact c{get;set;} public Event e; private final ApexPages.StandardController controller; public JoinMeContactController(ApexPages.StandardController controller) { this.controller = controller; c = new Contact(); c = [select id from Contact where Id=: ApexPages.currentPage().getParameters().get('Id')]; } public void newEvent(){ e = new Event(); e.WhoId = c.Id; e.Subject = 'Join.me Meeting'; e.ActivityDateTime = DateTime.now(); e.DurationInMinutes = 30; e.JoinmeV2__Join_Me_Activity__c = true; e.JoinmeV2__Meeting_Code__c = 'thewealthpool'; insert e; } public String getEvent(){ return e.Id; } }
Check in controller with system.debug if it is having the value.
Refer below code if that can help you.
http://sfdcsrini.blogspot.com/2014/07/visualforce-action-function-example.html
Best Regards,
Sandhya
You can use in this code reRender or return false.
I hope it will work.
<apex:page id="pg" standardController="Contact" extensions="JoinMeContactController">
<script>
function openPage (){
alert(GettingEvent());
var win = window.open('https://www.join.me', '_blank');
win.focus();
}
</script>
<apex:form >
<apex:actionFunction name="GettingEvent" action="{! getEvent}" reRender="imgId"/>
<apex:commandbutton image="{!URLFOR($Resource.JoinMeLogo)}" style="width:125px; height:125px; background:black; margin:0" onClick="openPage();return false;" action="{! newEvent}" reRender="imgId"/>
</apex:form>
</apex:page>
Please mark it as best Answer if you find it helpful.
Thank You
Ajay Dubedi