0

I want to convert a User Lookup to be displayed as dropdown (Picklist) in add screen. We have a Custom Field to display Users in Opportunity Create Page.

I have written a Custom Apex Controller by extending a Base Controller based on the Salesforce Documentation. I created a Visual Force Page to populate the Users in PickList and i can able to see and drag and drop the Visual Force page in (Setup->Customize->Opportunity->Page Layouts) Opportunity page layout.

After saving the layout i can able to see the Picklist in Opportunity View Page but i am not able to see my Visual Force page in Opportunity Create or Edit Screens. I am pasting my Code Below

<apex:page standardController="Opportunity" extensions="OpportunityControllerExt">
    <apex:form >
        <table>
            <tr>
            <td>
               Manager
            </td>
            <td>
                <apex:selectList value="{!Opportunity.RegionalSalesManager__c}"   multiselect="false" size="1">
                    <apex:selectOptions value="{!users}"/>
                </apex:selectList>
            </td>
            </tr>
        </table>

    </apex:form>
</apex:page>

Controller Class

public class OpportunityControllerExt {
    private Opportunity oppor;
    public OpportunityControllerExt(ApexPages.StandardController stdController) {
        this.oppor = (Opportunity)stdController.getRecord();
    }

     public ApexPages.StandardSetController setCon {
        get {
            if(setCon == null) {
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
                    [SELECT Id, name
                      FROM User
                      WHERE isActive = true]));
            }
            return setCon;
        }
        set;
    }

    // Initialize setCon and return a list of records
    public List<SelectOption> getUsers() {
        List<SelectOption> options = new List<SelectOption>();
        List<User> userslist=(List<User>) setCon.getRecords();
        if(userslist!=null){
            for (User myUser: userslist) {
              options.add(new SelectOption(myUser.Id,myUser.name));
            }
        }
        return options;
    }
}
  • The visualforce page will be available inline only in detail pages not in edit pages. You can comment and vote on this idea to get it implemented sooner success.salesforce.com/ideaview?id=08730000000Br8CAAS – Vigneshwaran G Dec 16 '15 at 13:04
  • 1
    Thanks for you spontaneous response and Clarifying my question Vigneshwaran, So we have to wait until salesforce announce it. – Saks Dec 16 '15 at 13:13
1

You are out of luck because it is not possible to add a visualforce pages to the Edit/New page layout.

However you can override a standard New and/or Edit buttons, create your own layout using a visualforce pages and redirect users to that pages after they click on New or Edit.

Here is some useful information: Override Standard Buttons and Tab Home Pages

| improve this answer | |
  • Mast0r Please confirm me that can i make the entire opportunity fields in a custom Visual Force Page and add that page by creating a new layout whether it will work and satisfy my needs?. i.e creating a Visual Force Page and adding all the fields and converting all the Lookups as Picklist and using that Visual Force Page in new Layout. – Saks Dec 16 '15 at 13:30
  • @Saks Yes you are right. But you do not need to create an extra page layout for Edit or New. Your visualforce pages will attend as "layouts". It is simple: user clicks on the Edit button on the record's page layout and redirected to the visualforce page you have defined, not to the standard edit layout. And yes, you can put all editable fields to the visualforce page. Then adjust the look and feel so the user will think he is on the "standard" page layout. – Sergej Utko Dec 16 '15 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.