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
SpunkySpunky 

Override standard "New Event " behavior

Wondering if someone can help me with this issue or suggest a better way of doing this.

 

I have a Visualforce "Event" page layout that is comprised of standard event fields and a bunch of custom activity fields.

 

I need an event Id in order to get the VF page to work.

 

I can't use apex class right now to drive page behavior because our test classes are beneath the governer limit and I don't have any development resources to fix that ..huge bummer.

 

So the solution I came up with is

1) I have a custom link on the opportunity that calls an scontrol(code below)

2)I want to utilize URL parameters[save & ret] to associate that saved event id to the VF page in edit mode so users can fill out the additional fields and then save it. 

 

Can I do this and how? So far the code I pasted below, creates the event and saves it but i'm not sure how to redirect it to my '/apex/eventdetails' page.

 

I would really appreciate some help

<script type="text/javascript">
window.parent.location.href="{!URLFOR($Action.Activity.NewEvent,null,
[evt3_lkid=Opportunity.Id,evt3=Opportunity.Name,evt5="Schedule CP",save=1,retURL=URLFOR($Action.Opportunity.View, Opportunity.Id)],true
)} &RecordType=01280000000G7PPAA0&type=Event&setupid=EventRecords";
</script>

 

 

 

 

 

 

joshbirkjoshbirk

The flow as I understand it is:

 

  1. User begins at Opp record (say ID foo).
  2. Clicks newEvent with the foo id to relate
  3. new Event is created
  4. user is redirected to /newEvent?id=event.Id

Normally the flow between 3 and 4 could easily be handled by a controller.  Here's a pure VF solution which does essentially the same thing:

 

<apex:page standardController="Event"  > 
<apex:includeScript value="{!URLFOR($Resource.jQuery, '/js/jquery-1.5.1.min.js')}"  />
<apex:outputPanel id="myevententry">
 	<apex:messages />
	<apex:form>	
  	Subject:<apex:inputField value="{!Event.Subject}" /><BR />
	Date:<apex:inputField value="{!Event.ActivityDateTime}" /><BR />
	Minutes:<apex:inputField value="{!Event.DurationInMinutes}" /><BR />
	
	<apex:inputHidden id="whatid" value="{!Event.WhatId}" />
	<apex:inputHidden id="eid" value="{!Event.Id}" />
	<apex:commandButton value="Save" action="{!quicksave}" />::{!Event.Id}
  </apex:form>
  <script>
	j$ = jQuery.noConflict();
	function init() {
		var whatid = window.location.href.split("wid=")[1];
		j$("[id$='whatid']").val(whatid);
		if("{!Event.Id}" != "") {
			window.location.href = "/apex/newevent?id={!Event.Id}";
		}
	}
	init();
  </script>
</apex:outputpanel>
</apex:page>

 

So if you link to /apex/thispage?wid=foo

 

And fill out the form, after the event is created the user will be taken to

 

/apex/newevent?id=bar

 

Obviously the form could use some cleanup, and I had to use jQuery because !Component was failing me.  But that should get you most of the way.

 

Side note: I'd have someone start revoking vacation days until your test coverage situation is fixed.  As you're finding, it is a very undesirable position to be in - and you'll be severaly hobbling yourself on the platform moving forward.  Situations like that should be development's job one to fix.

 

SpunkySpunky

Thank you so much.I'm going to try this out now.

 

Yes-I hear you on the coverage situation. It's very unfortunate because we really cant take things to the next level without rectifying that situation and unfortunately we dont have any developers to help.

 

Just me-but I will start giving it a try. I was able to get one to 100% coverage so thats a start:)

 

Thanks again.

joshbirkjoshbirk

No problem, let me know how it goes - and ping me if you've got unit test questions too....