You need to sign in to do that
Don't have an account?
Matt_F
Receiving System.TypeException: Invalid conversion from runtime type SOBJECT
Any help that can be provided will be greatly appreciated.
I'm not sure what the problem is, but I am receiving the following error:
System.TypeException: Invalid conversion from runtime type SOBJECT:Opportunity to SOBJECT:Value_Tests__c
Class.ValueTestExtension.<init>: line 5, column 1
Extension
public with sharing class ValueTestExtension { Opportunity o; Value_Tests__c vt; public ValueTestExtension (ApexPages.StandardController controller){ vt = (Value_Tests__c) controller.getRecord(); } public List<Value_Tests__c> getValueTests(){ return [SELECT actual_completion_date__c, approval_date__c, Outcome__C FROM value_tests__c WHERE OppID__c = :o.id]; } }
VF Page:
<apex:page standardController="Opportunity" extensions="ValueTestExtension"> <apex:pageBlock > <apex:pageBlockSection columns="1" title="Opportunity Detail Info"> <apex:outputField value="{!opportunity.name}"/> <apex:outputField value="{!opportunity.ownerId}"/> </apex:pageBlockSection> <apex:pageBlockSection columns="1" title="Value Test Info"> <apex:pageBlockTable value="{!ValueTests}" var="vt"> <apex:column value="{!vt.Actual_Completion_Date__c}"/> <apex:column value="{!vt.Approval_Date__c}"/> </apex:pageblockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:page>
Again, I appreciate any help you can give me.
Thanks,
Matt
Your VF page uses the "Opportunity" standardController. So the type of the controller.getRecord() record is "Opportunity". So what this error is saying is that you cannot cast an Opportunity to a Value_Tests__c at line 5.
What you probably want to do is:
Good luck!
Thanks a lot, John. That worked. But now I have a new problem. For some reason, no data will show under the Value Test Info section. I am trying to create a form for users to fill out to request a value test (which is the value_tests__c object). Do you think I am going down the correct path?