You need to sign in to do that
Don't have an account?
Vladimir Bessonov
object factory
Hi. I create a class and trigger with the purpose to insert list of objects with master - detail relation when after master is created.
I did it, but I store several lists in this class. it looks ugly.
How I can separate this several objets with properties from the class?
Is it possible just to keep them in SF database? is it good idea or it is a wrong direction?
I was thinking to make object factory, so I might pass only the list of objects I want to create and the factory will return me the list of objects to insert.
I did it, but I store several lists in this class. it looks ugly.
How I can separate this several objets with properties from the class?
Is it possible just to keep them in SF database? is it good idea or it is a wrong direction?
I was thinking to make object factory, so I might pass only the list of objects I want to create and the factory will return me the list of objects to insert.
Greetings!
We can't get the list of Sobjects using the SOQL query but you can make the describe call to get the list.
Please find the sample code below:
Run this code in Execute anonymous and check debug. You will get all the sobject name(API Name), label and other properties.
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
Also, I cannot get any clear answer from the Salesforce community how to organize the code.
I need to store some config objects that consist for sake of simplicity several List<String>.
I build an app. Based on the project selected I wanted to use different configs for automatic record creation.
I made a map
public without sharing class ProjectMap {
public ProjectMap() {
// how to make universal use of class?
// how to make generic object type,
CTAPropSet CTAProject = New CTAPropSet();
// PartSet cta = (PartSet) CTAProject;
Projects.put('CTA-CRRC', CTAProject);
}
Map<string, CTAPropSet > Projects = new Map<string, CTAPropSet >();
public Object projectConfig(String ProjectName) {
return Projects.get(ProjectName);
}
}
but as data always saved in classes and classes have names and data is of particular class type.
I hardcode the class type returned by MAP. I cannot figure out how to cast it
ProjectMap projectConf = New ProjectMap();
System.debug(ProjectName);
CTAPropSet projectConfLists = projectConf.projectConfig(ProjectName);
instead of CTAPropSet, I wanted to have some generic type that can be used if I enter the different project name.
Maybe it is possible to cast them to the same class as they will have the same structure.
Apex is pain. Why Salesforce cannot use just JS or typescript? I cannot find good and short documentation and code guides.
I work with salesforce for 3 weeks and I hate it already