• Chris Countey
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 6
    Replies
Hello all,
 
I'm trying to populate a selectList with data from the User object. This application is going to be used to provide feedback to internal SalesForce users about best practices.
 
Each page has a custom tab, "Provide Feedback:, that takes them to a VisualForce page. Before now, the dropdown for the users was empty. I added some code to my extension class and got the error below when I click on the feedback tab:

System.TypeException: Invalid conversion from runtime type SOBJECT:Feedback__c to SOBJECT:User

Class.NewFeedbackExtension.<init>: line 9, column 24
External entry point
 
NewFeedbackExtension
Code:
public class NewFeedbackExtension {
 
 private final Feedback__c feedbackObj;
 private final User userObj;

    public NewFeedbackExtension(ApexPages.StandardController controller) {
     
     this.feedbackObj = (Feedback__c)controller.getRecord();
     this.userObj = (User)controller.getRecord(); //this is line 9

    }
    
   
 
 
 public String selectedUser {get;set;}
    public List<SelectOption> userList;
    public List<SelectOption> getUsers() { 
     if (userList == null) {
          List<User> usrs = [select id,Name from User];
              userList = new List<SelectOption>();    
              for (User u : usrs) {     
                userList.add(new SelectOption(u.id, u.Name));  
           }
    }
                      
     return userList;
                      
    
    }

 
}

NewFeedback.apex
Code:
<apex:page standardController="Feedback__c" extensions="NewFeedbackExtension">

<h1>Provide Feedback</h1>

  <apex:form >
  
                <apex:pageBlock title="Enter New Feedback">
                       <apex:pageBlockButtons >
                       <apex:commandButton action="{!save}" value="Save"/>
        </apex:pageBlockButtons>
                       
                       
                       <apex:pageBlockSection title="Feedback Details" columns="2">              
                       <apex:selectList value="{!selectedUser}"/>
                       <apex:inputField value="{!Feedback__c.URL__c}"/>
                       <apex:inputField value="{!Feedback__c.Details__c}"/>
                       </apex:pageBlockSection>
                </apex:pageBlock>
  </apex:form>
        
        
  
   </apex:page>

 The dropdown <apex:selectList value="{!selectedUser}"/> should be populating all users' names and id's. I would love to have a search box associated with this list as it would help find users faster, but one step at a time. :smileyhappy:
 
Thank you in advance for your assistance.

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


Hello all,
 
I'm trying to populate a selectList with data from the User object. This application is going to be used to provide feedback to internal SalesForce users about best practices.
 
Each page has a custom tab, "Provide Feedback:, that takes them to a VisualForce page. Before now, the dropdown for the users was empty. I added some code to my extension class and got the error below when I click on the feedback tab:

System.TypeException: Invalid conversion from runtime type SOBJECT:Feedback__c to SOBJECT:User

Class.NewFeedbackExtension.<init>: line 9, column 24
External entry point
 
NewFeedbackExtension
Code:
public class NewFeedbackExtension {
 
 private final Feedback__c feedbackObj;
 private final User userObj;

    public NewFeedbackExtension(ApexPages.StandardController controller) {
     
     this.feedbackObj = (Feedback__c)controller.getRecord();
     this.userObj = (User)controller.getRecord(); //this is line 9

    }
    
   
 
 
 public String selectedUser {get;set;}
    public List<SelectOption> userList;
    public List<SelectOption> getUsers() { 
     if (userList == null) {
          List<User> usrs = [select id,Name from User];
              userList = new List<SelectOption>();    
              for (User u : usrs) {     
                userList.add(new SelectOption(u.id, u.Name));  
           }
    }
                      
     return userList;
                      
    
    }

 
}

NewFeedback.apex
Code:
<apex:page standardController="Feedback__c" extensions="NewFeedbackExtension">

<h1>Provide Feedback</h1>

  <apex:form >
  
                <apex:pageBlock title="Enter New Feedback">
                       <apex:pageBlockButtons >
                       <apex:commandButton action="{!save}" value="Save"/>
        </apex:pageBlockButtons>
                       
                       
                       <apex:pageBlockSection title="Feedback Details" columns="2">              
                       <apex:selectList value="{!selectedUser}"/>
                       <apex:inputField value="{!Feedback__c.URL__c}"/>
                       <apex:inputField value="{!Feedback__c.Details__c}"/>
                       </apex:pageBlockSection>
                </apex:pageBlock>
  </apex:form>
        
        
  
   </apex:page>

 The dropdown <apex:selectList value="{!selectedUser}"/> should be populating all users' names and id's. I would love to have a search box associated with this list as it would help find users faster, but one step at a time. :smileyhappy:
 
Thank you in advance for your assistance.

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


I am new to visual force and currently trying to create a multistep wizard page. The issue I have is how to specify the stage field based on a specific sales process and saving the opportunity to a specific recordtypeID. Any direction would be much appreciated.
  • September 03, 2008
  • Like
  • 0