+ Start a Discussion
Sfdc_beginnerSfdc_beginner 

Is it possible /advisable to update two custom objects using a single custom controller ?

HI There,

 

I am new to Salesforce,  I just want to know if it is possible to update two custom objects using a single custom controller (From Visual Force custom page) ? Is it advisable ? If Yes, please share an example .

 

And one more thing, how to create a look field in a custom VF page and how to populate the values from a lookup field in a custom object ?

 

Thanks in adavnce :)

 

crop1645crop1645

Custom controllers can certainly be used to update multiple SObject types - custom or standard. Standard controller extensions can also do this.

 

For an example of a custom controller that updates multiple SObject types - see VF Dev Guide here: http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/pages_quick_start_wizard.htm

 

Be sure to use try-catch blocks in your controller around DML statements

Sfdc_beginnerSfdc_beginner

Thanks Eric !

 

How about my 2nd question ?

 

How to create a look field in a custom VF page and how to populate the values from a lookup field in a custom object ?

Please share an example

 

 

Thanks in advance

Mayank_JoshiMayank_Joshi
if you refer any field in Vf with data type as lookup .then they will inherit the lookup properties directly in VF code .

Also , to populate values in Lookup field ,you need to pass expected Record Id to the lookup field . As Lookup can only be referenced through Ids for relating two objects .
Sfdc_beginnerSfdc_beginner

HI Mayank,

 

Thanks .

 

Request you to share an example code.

crop1645crop1645
<apex:inputField value="{!Opportunity.accountId}"/>

 Allows for a lookup field just like in standard SFDC page layout for the Opportunity's possible accounts (governed by any lookup filters defined in the Force.com UI

 

If you are trying to implement a custom lookup button, please read this: http://bobbuzzard.blogspot.com/2010/09/visualforce-lookup.html