function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vikmacvikmac 

Error in APEX Trigger

Hello

 

I am writing an APEX trigger (after update) on custom object, in which I am using the standard object as -

 

Products p = [select p.products__c from product p];

 

I am getting the following error -

 

Error: Compile Error: sObject type 'Products' 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 5 column 18

 

Please help...

wesnoltewesnolte

Hey

 

Small error:

 

 

Products p = [select p.products__c from product p];

 

Remove that S and you should be okay.

 

Cheers,

Wes

wesnoltewesnolte

And if you expect more than one result use a list to hold the query results e.g.

 

List<Product> products = [select p.products__c from product p];

 

Wes

vikmacvikmac

Hey

 

Removing that 's' didn't solve the problem. Still getting an error as -

 

  Error: Compile Error: sObject type 'Product' is not supported. at line 2 column 23  

 

Please suggest some solution.

 

Thanks

wesnoltewesnolte

Hey

 

I assumed Product was a standard object but it doesn't seem to be. Try this instead

 

List<Product__c> products = [select p.products__c from product__c p]; 

 

Wes

vikmacvikmac

Hey

 

Products is a standard object..

 

Even I am wondering why am I getting this error...

wesnoltewesnolte

Sorry dude, don't use the standard objects much. Here's the fix though, the products object is called product2 via the api. Try selecting from the object instead.. should sort you out.

 

Wes