You need to sign in to do that
Don't have an account?

Save method and id's in wizard
For the record-this is a question from "a have to be but am not developer ".
I hacked the opportunity wizard code to create a wizard that would allow me to
- retrieve an opportunity record
- Create an Event
- Retrieve fields from a Custom Object related to the opportunity called "Job_Aids__c"
It sort of works and I lack the exoertise to make this fully functional so any help would be greatly appreciated.
The Event does save but I need the event what id realted to the opportunity.id .
My attempt to do this is shown in line 39 but it throws back an error.
The other piece of it is the custom object. I'd like to be able to update the field values and save it. What would the save method be?
Thank you soo much in advance.
Controller Code
public class newOpportunityControllerrevA { Opportunity opportunity; Event event; Job_Aid__c jac; public Event getEvent() { if(event == null) event = new Event(); return event; } public Opportunity getOpportunity() { return [select id, name,amount,closedate,stagename,sales_stage__c from Opportunity where id = :ApexPages.currentPage().getParameters().get('id')]; return opportunity; } public Job_Aid__c getJob_Aid() { return [select id, createddate,U_opportunityname__c,X3rd_party_pressuring_improved_bus_perf__c,text__c from Job_Aid__c where U_opportunityname__c = :ApexPages.currentPage().getParameters().get('id')]; } public PageReference step1() { return Page.OpptyStep1; } public PageReference step2() { return Page.OpptyStep2; } public PageReference step3() { return Page.OpptyStep3; } public PageReference save() { //event.whatid = opportunity.id; insert event; PageReference opptyPage = new PageReference('/' + event.id); opptyPage.setRedirect(true); return opptyPage; } }
<apex:page controller="newOpportunityControllerrevA" tabStyle="opportunity"> <apex:form > <apex:pageBlock > <apex:pageblockbuttons > <!-- <apex:commandButton action="{!step2}" value="step2button"styleClass="btn"/>--> <!--<apex:commandButton action="{!step1}" value="Previous" styleClass="btn"/>--> <!-- <apex:commandButton action="{!step3}" value="Next" styleClass="btn"/>--> <apex:commandButton action="{!save}" value="Save" styleClass="btn"/> </apex:pageblockbuttons> <apex:pageBlockSection title="Event"> <apex:panelGrid columns="2"> Related To:<apex:inputfield value="{!event.whatid}" /> Subject:<apex:inputField value="{!Event.Type}" /><BR /> Subject:<apex:inputField value="{!Event.Subject}" /><BR /> Date:<apex:inputField value="{!Event.ActivityDateTime}" /><BR /> Minutes:<apex:inputField value="{!Event.DurationInMinutes}" /><BR /> </apex:panelGrid> </apex:pageBlockSection> <apex:pageBlockSection title="JOb Aid" > <apex:panelGrid columns="1"> {!job_aid.id} JOb aid field<apex:inputField id="jafield" value="{!job_aid.X3rd_party_pressuring_improved_bus_perf__c}"/> JOb aid field<apex:inputField id="jafield2" value="{!job_aid.Text__c}"/> </apex:panelGrid> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
In your save() method, you need to insert the opportunity first. You will then have the opp ID available for the Event and for your custom object's reference.
Any pointers on how do I do that?
I tried adding the line below under the save method but it threw back an eeror so I assume it's a little more than that.
insert opportunity;