You need to sign in to do that
Don't have an account?
Kim Bryant
Apex Class error 'variable does not exist' when trying to reference a custom object
Trying to write a apex class for making Salesforce and PayPal work via Form Assembly. I've created a custom object called Donation and am using a template coding provided by From Assembly support (http://www3.formassembly.com/blog/doc/connectors/salesforce/advanced-integration/making-salesforce-and-paypal-work-together/). I changed the code to replace where it referenced Opportunity to reference my custom object Donation__c. But I get the error ' Error: Compile Error: Variable does not exist: donation__c at line 8 column 9'. Below is the cod I'm using. Any Ideas?
public class IPNHandlerController {
public PageReference myIPNupdate() {
try{
PageReference pageRef = ApexPages.currentPage();
//Get the value of the 'custom' parameter from current page
String paramCustom = pageRef.getParameters().get('custom');
donation__c = [select Id,paid__c from Donation__c where FormAssemblyID__c = :paramCustom ];
String content = '';
for(String key : pageRef.getParameters().keySet()){
//Note that there is no guarantee of order in the parameter key map.
content += key + ' : ' + pageRef.getParameters().get(key) + '\n';
}
Donation__c.PayPalInfo__c = content;
Donation__c.paid__c = True;
update Donation__c;
PageReference newPage = new ApexPages.StandardController(Donation__c).view();
newPage.setRedirect(true);
return newPage;
} catch (System.Exception e){
//A failure occurred
system.debug(e);
return null;
}
}
public Opportunity opportunity {get; set;}
public IPNHandlerController() {
}
}
public class IPNHandlerController {
public PageReference myIPNupdate() {
try{
PageReference pageRef = ApexPages.currentPage();
//Get the value of the 'custom' parameter from current page
String paramCustom = pageRef.getParameters().get('custom');
donation__c = [select Id,paid__c from Donation__c where FormAssemblyID__c = :paramCustom ];
String content = '';
for(String key : pageRef.getParameters().keySet()){
//Note that there is no guarantee of order in the parameter key map.
content += key + ' : ' + pageRef.getParameters().get(key) + '\n';
}
Donation__c.PayPalInfo__c = content;
Donation__c.paid__c = True;
update Donation__c;
PageReference newPage = new ApexPages.StandardController(Donation__c).view();
newPage.setRedirect(true);
return newPage;
} catch (System.Exception e){
//A failure occurred
system.debug(e);
return null;
}
}
public Opportunity opportunity {get; set;}
public IPNHandlerController() {
}
}
All Answers
donation__c is the SObject TYPE you need to name it. For example donation__c donatationObj = [Select ....
would do the trick.