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

Automatically pre-populate VFpage Lookup
Hi. I have a VFpage which mimics the layout of an object in my org. The intention is to have a custom Add and Save button on the create/edit screen.
The VFpage is as follows:
<apex:page standardController="Call__c" extensions="TimesheetFindSOQL"> <apex:sectionHeader title="Call__c Edit" subtitle="{!Call__c.name}"/> <apex:form > <apex:pageBlock title="Call__c Edit" mode="edit"> <!--buttons for the VFpage at the top--> <apex:pageBlockButtons location="top"> <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Save & New" action="{!save}" /> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <!--buttons for the VFpage at the bottom--> <apex:pageBlockButtons location="bottom"> <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Save & New" action="{!save}" /> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <!--Fields from Call object with mandatory/non-mandatory flag indicators--> <apex:pageBlockSection title="Information" columns="2"> <apex:inputField value="{!Call__c.Account__c}" required="true"/> <apex:inputField value="{!Call__c.Timesheet__c}" required="true"/> <apex:inputField value="{!Call__c.Contact__c}" required="false"/> <apex:inputField value="{!Call__c.RecordTypeId}" required="false"/> <apex:inputField value="{!Call__c.Call_Date__c}" required="false"/> <apex:inputField value="{!Call__c.Call_Category__c}" required="false"/> <apex:inputField value="{!Call__c.Call_Notes__c}" required="false"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
Tthe aim here is to populate
<apex:inputField value="{!Call__c.Timesheet__c}" required="true"/>
with the result of some SoQL.
I have a class, but my issue is what on earth to do with these two entities:
public with sharing class TimesheetFindSOQL { public TimesheetFindSOQL(ApexPages.StandardController controller) { } //instance variable public Timesheet__c record {get; set;} //class constructor public TimesheetFindSOQL() { List<Timesheet__c> records = [Select Id, Name From Timesheet__c WHERE Week_Beginning__c = 2013-03-25]; if(!records.isEmpty()) { record = records.get(0); } record = records.get(1); } }
Where do I go from this point?
Try the above code.
Ok that seems fine, no errors when put in, thanks so far! I need to take the next logical step which is to make that run from the VFpage.
My logic dictates that I would need something like:
as the next step in the VFpage to make thatTimesheetFindSOQL perform its action. My lack of structure knowledge is hampering me though.
I *think* (from what I read) you need a custom controller up where you kick off with <apex:page and then to define what action that controller takes. Although that is a very tentative assumption.