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
THBrunoTHBruno 

Use of classes with Custom Objects

Hi,

 

I'm wondering what the best approach is when developing an application with custom objects & classes.

 

We created custom objects and would like to create some kind of assistance class for each object.

 

Example:

- custom object car: Car__C

- we need custom methods for the creation and deleting (createCar, removeCar)

- but also for changing (example: addTyre(4); )

 

Has salesforce something standard to support us? Do we need to create those classes ourselves (with the possibility of a static call)?

Or do salesforce has something built-in where we can add methods to custom objects? If so, are there already methods we can call on custom objects?

 

What is the best approach?

 

Kind regards,

 

Bruno

                  

Shailesh DeshpandeShailesh Deshpande
HI Bruno,

When you create a custom object, you do have standard functionalities available with it like New, edit, delete. You can use these for your cars object to create a car(using New), modify a car (using Edit), remove a car (using Delete). However this will behave exactly in the same manner as your standard objects New, Edit or delete works. When you want to over ride the standard functionality provided by salesforce you need to create classes/pages or override standard buttons like New, EDIT, Delete etc.
Satish_SFDCSatish_SFDC
I normally use a static class per salesforce object, with some static methods.
The trigger acts a dispatcher and calls the specific method on the static class to process the request. I also pass the trigger context variables to the methods.

Regards,
Satish Kumar
THBrunoTHBruno

Thanks for the replies!

 

We will proceed in this way.