You need to sign in to do that
Don't have an account?

Compile Error: Incompatible types since an instance of SObject is never an instance of Campaign
Hi,
I'm trying to create a controller extension for Campaigns and get the following error:
Compile Error: Incompatible types since an instance of SObject is never an instance of Campaign at line 7 column 32
My extension class is the following:
public class CampaignControllerExtension { private ApexPages.standardController controller {get;set;} private Campaign currentTraining; public CampaignControllerExtension(ApexPages.StandardController stdController) { controller = stdController; this.currentTraining = (Campaign)stdController.getRecord(); } }
Apparently there is an exception on Campaigns Sobject but I didn't find any clue on how to correct this.
Any Ideas?
thanks,
Hi try to this code..
--------------------
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
Thanks
Sorry this was a mistyping, I corrected, but the problem is still there.
Cloudy,
Check your Apex classes-my assumption is that you have an Apex class named 'Campaign' that is causing this issue. In this case, the apex logic you have written would be trying to cast the SObject to an instance of this custom Campaign class, rather than to an instance of the standard Campaign object as you intend. Hope that helps!