You need to sign in to do that
Don't have an account?
Why Custom Field's (Picklist - Data Type) values are not appearing on VF Page(PageBlockTable-Column)?
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 class - ContactSearchController
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.
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.
Suppose you have two picklist Level__c and interested_technologies__c
1. Level__c picklist have three values .... 1 , 2, 3
and
2. interested_technologies__c has three values .. IT, CS, TD
and Suppose you have 5 Contacts stored in your org there are
Name Level Technologies
Mr. A 1 IT
B 1 CS
C 3 IT
D 2 TD
E 1 IT
Now what do you want to show on vf page?
like table I created above
Or
Just Possible Picklist values as given blow
1
2
3
IT
CS
TD
Currently You are not querying your contacts, You just created SOQL String.
If you want to show Contacts list in table on vf page , you just need to write this code in Constructor of your class
Thanks & Regards
Sameer Tyagi
http://mirketa.com/
Thanks for the reply with guidlines.
Yes, you are right about Querying contacts. I was missing it earlier to mention here but even after it doesn't work.
And I want to just retrieve values in the table just like you shown in the example as follows:
Name Level Technologies
Mr. A 1 IT
B 1 CS
C 3 IT
D 2 TD
E 1 IT
Still the scneario is the same, values of Technologies are not appearing but Levels.
Could you please guide me why it is happening?
Thanks and regards,
Onkar Dhane.
<apex:page controller="ContactSearchController ">
<apex:form>
<apex:pageBlock>
<apex:pageblockTable value ="{!con}" var ="a">
<apex:column value ="{!a.conlist.name}" headerValue="Name"/>
<apex:column value="{!a.conlist.level__c}" headerValue="Level"/>
<apex:column value="{!a.conlist.cleanstatus}" headerValue="Status"/>
</apex:pageblockTable>
<apex:commandButton value ="submit" action="{!givedetails}"/>
</apex:pageBlock>
</apex:form>
</apex:page>
ApexClass:
public with sharing class ContactSearchController {
Public list<conwrap>con{get;set;}
Public ContactSearchController (){
con = new list<conwrap>();
}
list<account> acclist = [select id ,name,(select id,name ,level__c,cleanstatus from contacts) from account];
Public void givedetails(){
for(integer i=0;i<acclist.size();i++){
for(integer j=0;j<acclist[i].contacts.size();j++){
conwrap SWC = new conwrap();
SWC.conlist = acclist[i].contacts[j];
SWC.connames = acclist[i].contacts[j].name;
con.add(swc);
}
}
}
public class conwrap{
Public contact conlist{get;set;}
Public boolean isselected{get;set;}
Public string connames{get;set;}
}
}