You need to sign in to do that
Don't have an account?
Chris Countey
Calling the {!User} object in a selectList and problems with custom controllers
Hello all,
I'm very new at SalesForce and I have read through most of the documentation and developed the Mileage application from the workbook, but I'm still struggling with what should be a simple task.
Here is the scenario in a nutshell:
I am developing a custom application that a corporate team will use to provide feedback to new SalesForce users about how they are using the SalesForce platform.
Below is the VisualForce page the corporate team will see to submit new feedback. Obviously not finished, but this is the basic idea: select a SFDC user from the {!Users} object, enter the URL of the page in question, and create a message.
How does one pull in the data from the Users object and use it in the selectList? In a standard SalesForce form, related fields open a dialogue where you can either select or search for users. Is there any way to call that functionality from your VisualForce page?
Code:
<apex:page standardController="Feedback__c"> <h1>Provide Feedback</h1> <apex:form > <apex:pageBlock title="Enter New Feedback" mode="insert"> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Save"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Feedback Details" columns="2"> <apex:selectList value="{????}"/> <apex:inputField value="{!Feedback__c.URL__c}"/> <apex:inputField value="{!Feedback__c.Details__c}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form>
I understand that methods can be written in your controller class that may be able to accomplish this task, but this brings me to my second very newbie question: Why when I create a custom controller does my {!save} method no longer work?
I found this very helpful code below, but I can't seem to use it because I lose all functionality when I switch away from the standardController and use a custom controller class instead.
Code:
public class NewFeedbackController { public String selectedUser {get;set;} public List<SelectOption> userList; public List<SelectOption> getUsers() { if (userList == null) { List<User> usrs = [select id,firstname,lastname from user]; userList = new List<SelectOption>(); for (User u : usrs) { userList.add(new SelectOption(u.id, u.firstname + u.lastname)); } } return userList; } }
Thanks in advance for your assistance!
Chris
<apex:page standardController="Account" extensions="myControllerExtension">
Hope this helps
Just to make sure I'm on the same page, I can create methods in my extension(s) that can be referenced in my VisualForce page? And can I use more than one extension?
Thanks!
The extension controller applies to VF pages who use the standard controller in order to add more functionality. The extension is a class so you can have all the methods you need. In these methods you may reference whatever apex classes you have so I don't think there's a need for more than 1 extension.