You need to sign in to do that
Don't have an account?
gregusa
Why does referencing the Record Type on a custom object throw a system error?
I have a custom controller for a custom object. When I include this code on the visualforce page:
I get the following error:
I'm having a hard time understanding coding for RecordTypes. Can anyone point me in the right direction?
Code:
<apex:pageBlockTable value="{!over}" var="a" id="table"> <apex:column headerValue="Record Type"> <apex: <apex:inputField value="{!a.RecordType}" /> </apex:column> </apex:pageBlockTable>
I get the following error:
Code:
An internal server error has occurred An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact support@salesforce.com. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience. Thank you again for your patience and assistance. And thanks for using Salesforce! Error ID: 1550134988-19307 (1773106477)
A few things I see.
First, are you retrieving the Recordtypeid field when you create the list called "over"
Second, RecordType is not the name of any field, so this would cause an error.
you could use RecordType.Id, but, chances are, depending on your ultimate goal, that won't be enough.
If you are allowing the user to select the record type, you will want to create a select option list with the
possible record types for that object, and allow the user to select by name. Also, note that since dependent picklists aren't supported
you will have to control which options are valid for the user programatically.
Here is a code snippet that will create a list of record types for the Account object, you could start with this:
I don't understand how to bind the selected value from the SelectOption to the RecordTypeID of the custom object. As you'll see below, I plugged in your code for RecordTypes, both in the Page and the Controller. However when I try to save the code I get the following error: Unknown property 'RecordType'.
Here's a scaled down version of my Visualforce page:
and the Controller...
It is odd that you get that error when saving the apex code. That would imply that you don't have visibility to the RecordType object in your org. Do you? Can you see the RecordType object using something like the Apex Explorer, or even the schema viewer in Eclipse?
Correcting this issue is your first order of business.
Your other option would be to get the recordtypeid's yourself, and manually build the select option list.
Now, as for binding this select result into your record when saving, this is what I would do.
Change your Save code like this:
you will need to add a message tag to your selectlist component to display the error if the user didn't select any value.
However, problem with the save syntax you gave me:
I get the following error when trying to save that to the server: Save error: Initial term of field expression must be a concrete SObject: LIST:SOBJECT:Override__c (line 45)
your line 45 should read:
over.recordtypeid = recType;
but got the same error...
for testing, you could say over[0].recordtypeid = recType;
just to see if it works with one record in the array.