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
BARJRDBARJRD 

Qualify Lookup field on a standard Salesforce page

I have several record types defined for the Opportunity object.  Each record type uses a different page layout.

 

The Opportunity object contains a custom field "QBAccount" which is a lookup to object QBAccount.  QB accounts are categorized by Opportunity record type, so only the subset of QB Accounts matching a particular record type should be available for selection.

 

I created a custom button that calls a VF page (with the current record type as a parameter).  The VF page displays the QB accounts valid for that record type.  The user then selects a value ---- but I'm not sure how to plug this value into the QB Account field on the opportunity page.

 

Is there any way to do this without creating VF pages for each record type?

 

Thanks,

Barb

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

I'd suggest the following:

 

Pass the id of the opportunity object under consideration to the VF page.

Once the user has chosen the account, call an action method on your controller (either by the user clicking a button or through event handing and javascript).

In the action method, retrieve the opportunity via SOQL, set the id of the account into the appropriate field and update the opportunity using DML.

Return the pagereference for the opportunity as the result of the action method.

All Answers

bob_buzzardbob_buzzard

I'd suggest the following:

 

Pass the id of the opportunity object under consideration to the VF page.

Once the user has chosen the account, call an action method on your controller (either by the user clicking a button or through event handing and javascript).

In the action method, retrieve the opportunity via SOQL, set the id of the account into the appropriate field and update the opportunity using DML.

Return the pagereference for the opportunity as the result of the action method.

This was selected as the best answer
BARJRDBARJRD

Thanks, Bob... sounds like a good idea :-)