• Onkar DHANE
  • NEWBIE
  • 0 Points
  • Member since 2014
  • IT Consultant
  • Geviteam


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hello all,
I am new to SFDC and started development in Apex and Visualforce Page with tutorials and online samples. 
So, here what I have tried and got stuck at the point. 

What I am trying to achieve:
1. In VF page, I want to show Custom field's values of Picklist data type in tabular format (In one of the coulmn) and it should be as Outputfield but not as a Inputfield.
2. In VF page, I want to access Custom field's values of Picklist data type of my Custom Object in tabular format (In one of the coulmn) and it should be as Outputfield but not as a Inputfield.

What I have tried to achieve 1st use case:

1. In Contact custom fields, I have created new Custom Picklist "interested_technologies__c" and there was already custom field "Level__c"  of picklist data type. 
2. I have created VF ("CustomerSearch") and Apex class ("ContactSearchController") as follows:

VF Page - CustomerSearch
<apex:page controller="ContactSearchController" sidebar="false">

  <apex:form >
<apex:pageBlock mode="edit" id="results">

        <apex:pageBlockTable value="{!contacts}" var="contact">

      <apex:column headervalue="Technologies">
               <apex:outputField value="{!contact.interested_technologies__c}" rendered="true">    </apex:outputField>
            </apex:column>
            
      <apex:column headervalue="Levels">
                <apex:outputField value="{!contact.Level__c}" rendered="true">
                 </apex:outputField>
            </apex:column>

      </apex:pageBlockTable>
    </apex:pageBlock>
</apex:form>
</apex:page>

Apex class - ContactSearchController 
public with sharing class ContactSearchController {

  // the soql without the order and limit
  private String soql {get;set;}
  // the collection of contacts to display
  public List<Contact> contacts {get;set;}

 // init the controller and display some sample data when the page loads
  public ContactSearchController() {
    soql = 'select interested_technologies__c, Level__c from contact ';
  }

  // use apex describe to build the picklist values
  public List<String> technologies {
    get {
      if (technologies == null) {

        technologies = new List<String>();
        Schema.DescribeFieldResult field = Contact.interested_technologies__c.getDescribe();

        for (Schema.PicklistEntry f : field.getPicklistValues())
          technologies.add(f.getLabel());

      }
      return technologies;          
    }
    set;
  }
  
 // use apex describe to build the picklist values
  public List<String> levels{
    get {
      if (levels == null) {

        levels = new List<String>();
        Schema.DescribeFieldResult field = Contact.Level__c.getDescribe();

        for (Schema.PicklistEntry f : field.getPicklistValues())
          levels.add(f.getLabel());

      }
      return levels;          
    }
    set;
  }

}

Problem and queries:

1. Here, I can see  Picklist values on VF Page for "Levels" and not for "Technologies". 
2. This is bit wierd behaviour as everything is the same except "Level__c" custom field was already created and "interested_technologies__c" custom field which I created.
3. Am I missing or doing some mistakes here? Or Is there any accessibility issues?  
4. FYI, I can see both custom fields picklist values using inputfield. 
5. I am free user on Salesfroce and profile has been set as a System Administrator in my app. 

Any recommendations would be highly appreciated. 

Thanks and regards,
Onkar. 

 



 
Hello all,
I am new to SFDC and started development in Apex and Visualforce Page with tutorials and online samples. 
So, here what I have tried and got stuck at the point. 

What I am trying to achieve:
1. In VF page, I want to show Custom field's values of Picklist data type in tabular format (In one of the coulmn) and it should be as Outputfield but not as a Inputfield.
2. In VF page, I want to access Custom field's values of Picklist data type of my Custom Object in tabular format (In one of the coulmn) and it should be as Outputfield but not as a Inputfield.

What I have tried to achieve 1st use case:

1. In Contact custom fields, I have created new Custom Picklist "interested_technologies__c" and there was already custom field "Level__c"  of picklist data type. 
2. I have created VF ("CustomerSearch") and Apex class ("ContactSearchController") as follows:

VF Page - CustomerSearch
<apex:page controller="ContactSearchController" sidebar="false">

  <apex:form >
<apex:pageBlock mode="edit" id="results">

        <apex:pageBlockTable value="{!contacts}" var="contact">

      <apex:column headervalue="Technologies">
               <apex:outputField value="{!contact.interested_technologies__c}" rendered="true">    </apex:outputField>
            </apex:column>
            
      <apex:column headervalue="Levels">
                <apex:outputField value="{!contact.Level__c}" rendered="true">
                 </apex:outputField>
            </apex:column>

      </apex:pageBlockTable>
    </apex:pageBlock>
</apex:form>
</apex:page>

Apex class - ContactSearchController 
public with sharing class ContactSearchController {

  // the soql without the order and limit
  private String soql {get;set;}
  // the collection of contacts to display
  public List<Contact> contacts {get;set;}

 // init the controller and display some sample data when the page loads
  public ContactSearchController() {
    soql = 'select interested_technologies__c, Level__c from contact ';
  }

  // use apex describe to build the picklist values
  public List<String> technologies {
    get {
      if (technologies == null) {

        technologies = new List<String>();
        Schema.DescribeFieldResult field = Contact.interested_technologies__c.getDescribe();

        for (Schema.PicklistEntry f : field.getPicklistValues())
          technologies.add(f.getLabel());

      }
      return technologies;          
    }
    set;
  }
  
 // use apex describe to build the picklist values
  public List<String> levels{
    get {
      if (levels == null) {

        levels = new List<String>();
        Schema.DescribeFieldResult field = Contact.Level__c.getDescribe();

        for (Schema.PicklistEntry f : field.getPicklistValues())
          levels.add(f.getLabel());

      }
      return levels;          
    }
    set;
  }

}

Problem and queries:

1. Here, I can see  Picklist values on VF Page for "Levels" and not for "Technologies". 
2. This is bit wierd behaviour as everything is the same except "Level__c" custom field was already created and "interested_technologies__c" custom field which I created.
3. Am I missing or doing some mistakes here? Or Is there any accessibility issues?  
4. FYI, I can see both custom fields picklist values using inputfield. 
5. I am free user on Salesfroce and profile has been set as a System Administrator in my app. 

Any recommendations would be highly appreciated. 

Thanks and regards,
Onkar.