You need to sign in to do that
Don't have an account?
pooja biswas
bind recordtype to picklist
Hi
My requirement is to bind recordtypes to an picklist and display in visual force page
I have the code show in this post.
Its coming from the statement inside the for loop.
Pls let me know how to resolve this.
pooja
My requirement is to bind recordtypes to an picklist and display in visual force page
I have the code show in this post.
public with sharing class recordtypepicklist { public list<SelectOption> getRecordTypes() { list<SelectOption> options = new list<SelectOption>(); for(RecordType sRecordType:[select ID,Name from RecordType where SObjectType='Contact']) { options.add(new SelectOption(sRecordType.ID,sRecordType.Name)); } return options; } }I am getting an error as Error: Compile Error: Variable does not exist: ID at line 9 column 38
Its coming from the statement inside the for loop.
Pls let me know how to resolve this.
pooja
Try something like :
You will get to see :
Note: Mark this as solution if that resolves your issue.
All Answers
Are you sure that your inline query is returning rows ? I would break it out a little differently, something like this:
The key here is, to catch that query exception (it'll say something like list has no rows for assignment); before trying to add to the options.
Thanks for ur reply
I am getting an error as " Illegal assignment from List<RecordType> to List<recordtype> at line 15 column 10"
Its coming from the statement inside the try block.
This is strange because in workbench we have RecordType object. Could u pls let me know the issue?
thanks
pooja biswas
I do not have any custom object RecordType.
Try something like :
You will get to see :
Note: Mark this as solution if that resolves your issue.
I moved the entire code to another user account and it works.
But the picklist remains empty in visual force page.
Thanks
pooja
Did you try to run this QUERY in Developer Console and see if you are getting any rows ?
If you don't get any rows then your picklist will be empty.
Replace your controller like below :
Let me know if that helps!