I am new in apex programming. I am using site.com. I am creating New apex class using this code --
@isTest
private class HelloWorldTestClass {
static testMethod void validateHelloWorld() {
Book__c b = new Book__c(Name='Behind the Cloud', Price__c=100);
System.debug('Price before inserting new book: ' + b.Price__c);
// Insert book
insert b;
// Retrieve the new book
b = [SELECT Price__c FROM Book__c WHERE Id =:b.Id];
System.debug('Price after trigger fired: ' + b.Price__c);
// Test that the trigger correctly updated the price
System.assertEquals(90, b.Price__c);
}
}
but it gives me this error -Error: Compile Error: sObject type 'Book_c' is not supported. If you are attempting to use a custom object, be sure to append the '_c' after the entity name. Please reference your WSDL or the describe call for the appropriate names. at line 13 column 12.
help me out..
Have you actually created such object in your Salesforce instance? There are some standard objects (like User
) and you most likely also have the objects related to the CRM product (like Account
, Contact
, Opportunity
) but Book__c
will be a custom object created by you or another System Administrator in your organization.
Check Setup (upper right corner in web interface) -> Create -> Objects. There's a youtube tutorial or you can always click "Help for this page" link.
To expose this object on the Site (which means anybody in the world will be able to view and insert Books) you'll have to follow few more steps. But as it's a test class that fails to compile I think you haven't reached this problem yet. More info about permissions: http://login.salesforce.com/help/doc/en/siteforce_data_access_perms.htm