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
Kyle BuzzaKyle Buzza 

Open related event record edit page on Visualforce custom button

Hello,

I'm using a custom visualforce button that will create a related event record upon clicking it. Is there a way to open the edit page on this created event after it is created?

Here is the code:
<apex:page id="pg" standardController="Contact" extensions="JoinMeContactController">
    <script>
		function openPage (){
            var win = window.open('https://www.join.me', '_blank');
            win.focus();
		}
	</script>
    
    <apex:form >
        <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;}
    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(){
        Event 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;
    }
}