+ Start a Discussion
Lee SinLee Sin 

Visualforce page Custom object Lookup field pre-populating

I have been analyzing this topic for quite a few days.

The problem I am now facing is:

I have a custom Object "Task_Flow_Manager" on Account Detail page .
On clicking 'new' button of "Task_Flow_Manager", I am directed to a bridge page for selecting record type.
After selecting the record type, I click "continue" button to be directed to the real page for creating new object of "Task_Flow_Manager"

On the page for creating "Task_Flow_Manager", I have quite a lot Lookup fields related to dates or User object  to be populated.

A lot of solutions require URL hacking.
But I can not customize the 'new' button since it resides on a bridge page.

I also tried to set the value by using JavaScript "getelementByID", but somehow failed.

I am trying to create a Visualforce page myself and provide values to populate those Lookup fields
by using an Extension method.

However, I don't know how to give the "Apex:Inputfield" component a default value.
Best Answer chosen by Lee Sin
Florian HoehnFlorian Hoehn
Hi Victor,

You can prepopulate the apex:inputField by prepopulating the record/parameter that it is connected to.

<apex:inputField value="taskFlowManager.Custom_Field__c" />

Now just set this record even if it's a new one and populate this field in the controller or extension

taskFlowManager.Custom_Field__c = 'some value';

I hope this helps already.

Florian

All Answers

Florian HoehnFlorian Hoehn
Hi Victor,

You can prepopulate the apex:inputField by prepopulating the record/parameter that it is connected to.

<apex:inputField value="taskFlowManager.Custom_Field__c" />

Now just set this record even if it's a new one and populate this field in the controller or extension

taskFlowManager.Custom_Field__c = 'some value';

I hope this helps already.

Florian
This was selected as the best answer
Lee SinLee Sin
Thanks, I get it!