Questions tagged [bestpractice]

Referring to the use of recognized community and platform best practices. May relate to all areas of lifecycle and all development and administration activities.

Filter by
Sorted by
Tagged with
-1
votes
1answer
461 views

(Why?) Is it good for Apex methods to be static? [closed]

Many native objects in Apex rely on static methods and properties. This seems an abnegation of S.O.L.I.D., or at least of the Dependency inversion principle. As a developer who values the test ...
2
votes
2answers
227 views

(Why?) Is it good for Apex classes and methods to be final? [closed]

By default, in Apex, unlike Java and other OOP languages, all classes and methods are final. You aren't allowed to make this explicit and if you want things not to be final, you need to use the ...
9
votes
2answers
930 views

How to Reduce Repeated If/Else Logic in Code

I'm relatively new to Apex, and one thing I've found is there are a few places in my code where the same the same if/else logic is repeated. I.e. if (first_condition) { // do something } else if (...
3
votes
1answer
53 views

Best approach to translating numerous email templates

The Problem: I have approximately 30 different email templates that are being sent out to applicants during an application process. Applicants have 3 language options: English, French & Portuguese....
4
votes
1answer
78 views

What is too many functions?

While reading through on some lightning documentation I came across this piece regarding Anti-Patterns. I have definitely had some helpers which have run the risk of embodying that anti pattern. How ...
0
votes
1answer
26 views

Any Flaw in using below logic to avoid multiple time execution of a functionality in Trigger code?

I have a Trigger on an object, which is calling a method of other class(passing Trigger.New so that some functionality is executing depending on values of passed record) which should be called after ...
0
votes
1answer
35 views

Is it best practice to update an object based on Two objects?

I had to populate other objects data with an object ELE Agreements. I am not sure my code is best practice or not because I am using two Objects queries. I am afraid of any SOQL Limitation error ...
0
votes
1answer
683 views

How to mark a Salesforce Contract record as canceled or terminated?

I understand once a contract has been Activated, the status cannot be changed. However, there are times when a contract is terminated (ends early) and there needs to be a way to indicate this. Are ...
1
vote
1answer
210 views

Is that possible to enqueue more than one action? Please suggest

I just read the best practices article for the Lightning and I am wondering is that possible to have more than one enqueueaction in client controller js? Please suggest. There is some hint given in ...
1
vote
1answer
564 views

Trigger Best Practices - Multiple classes or single class?

I know a trigger best practice would not include logic within the trigger itself and this should be put in a separate class which is fine. However, if you have multiple operations being performed by ...
0
votes
1answer
76 views

Best Practices Regarding Formatted Data in Data Extensions

We're currently setting up a new data extension for our orders, and the previous data extension was importing every column as TEXT. This means that every query we run must first CAST or CONVERT these ...
1
vote
1answer
791 views

How to check field accessiblity of a field that is related to the object being checked

While developing secure controller actions for a Lightning Component, I ran across an issue checking accessibility for an Account level attribute related a Contact. For example: Schema.SObjectType....
0
votes
0answers
14 views

Safe to create custom object log records in a security-reviewed managed package app?

I want to create a logging system for our AppExchange managed package that will be recorded by Usage Metric features and will also comply with security guidelines to pass the review. To achieve ...
1
vote
2answers
94 views

Conditional logic or throwing an exception when checking FLS and object CRUD?

When checking Field-Level Security or object CRUD in Apex within a managed package, is it required to use conditional access to prevent the given operation (for the purposes of passing the security ...
4
votes
2answers
156 views

When (if ever) will testmethod fail to compile?

I just recently learned from the Apex Developer Guide documentation on the IsTest Annotation: The testMethod keyword is now deprecated. Use the @isTest annotation on classes and methods instead. ...
2
votes
1answer
121 views

Avoiding nested for Loops - finding sibling records

Background: I have a Children object that is child of Opportunity. When a Children record gets inserted/updated i want to find if there any other sibling(children) that is set as primary children if ...
5
votes
1answer
158 views

What value is there in an Application Service Provider

As I implement Andrew Fawcett's, Apex Common library referring to the fflib-apex-common-samplecode when necessary, I note that his ObjectService classes (i.e. OpportunitiesService.cls) are really more ...
9
votes
3answers
2k views

Is it good practice to initialize variable?

In the below class, I have a Map which I intend to use later in some function. Is it good practice that I intialize the Map with new Map(); or since it will get a value later when the method is ...
1
vote
1answer
236 views

What is clearReference(“v.attribute”) used for?

Did anyone ever use cmp.clearReference("v.attribute")? The documentation says it should be called before resetting attributes with component.set(), what sounds kind of useless to me. There are no use ...
5
votes
0answers
193 views

Possible to create a generic “invocable class” per object?

My organization is starting to feel some pain around using Process Builder + Flow (error handling mostly, but also inherent Flow inefficiencies and the inability to run Flow in system context). Thus, ...
1
vote
1answer
479 views

calling multiple helper methods with parameters

I have multiple helper methods and I need multiple arrays as parameters. My question is if is more efficient to get them in each method: component.get("v.someArray"); or call the function with this ...
7
votes
1answer
3k views

Lightning - Combobox vs Select

With the ever increasing base lightning components Salesforce is putting out, I'm always trying to move to the latest and greatest in hopes that through time, it will be supported better than legacy ...
21
votes
2answers
438 views

Friction-free process to switch to SalesforceDX with existing managed package

Dreamforce '17 made it crystal clear. Salesforce DX is ready for prime time. With Second-Generating Packaging SGP even for ISVs. Salesforce DX is awesome, nonetheless we fear that getting started ...
0
votes
1answer
36 views

Need some clarity in documentation about best practices on trigger [closed]

I have come across the Salesforce documentation on Trigger and Bulk Request Best Practices. Here is the link Trigger and Bulk Request Best Practices They have explained that " If more than 20 ...
2
votes
2answers
166 views

Best Practice for bulk removeEnd() edits

I have 35+ words that I need to search for within a string. If the string ENDS with any of the 35+ words then I need to remove them. I am using .removeEnd() and it works great. My issue is my method ...
3
votes
1answer
129 views

Apex Trigger: Is it better to update the current collection or create a new collection with only the records that meet the conditions?

Wanted to see what the 'better' practice is or which would provide better performance. Let's say I have a trigger like this: trigger ProjectTrigger on Project__c (after update) { ...
4
votes
2answers
326 views

Is better call a flow or code some APEX+Visual Force?

I am working on a basic solution, and I dont know why is better a Visual Flow than a Some Apex Code + Visual Force Page. I getting same Limits, and security can have the same issues. Someone knows ...
4
votes
2answers
1k views

Can I use platform event (which calls apex method) as alternative to future method?

Can I use platform event (which calls apex method) as an alternative to invoking future method from trigger? Is this against salesforce best practices?
2
votes
2answers
361 views

DML Statement vs. Database method with true parameter?

Database methods with a true parameter will work same as DML statements. It won't allow partial DML operation in Apex Why are we still using DML statement, when we can achieve the same functionality ...
0
votes
2answers
351 views

What is the best practice to update <version/> in package.xml?

For example, The current <version/> should be 40.0 (Summer '17). However, the latest MavensMate (v0.0.11-beta.7) uses 34.0. What are some best practices for updating <version/> in package....
0
votes
2answers
39 views

Do I use the existing Accounts object or create my own

I have a requirement for: 1) A Many-to-many relationship requirement between Accounts and Contacts which will utilize a junction object. 2) There will be a One-to-Many relationship between the ...
4
votes
1answer
1k views

How to use Contact Builder Data Model and Data Filters for Email Sends?

Thanks in advance for any advice! Imagine we have an All Subscribers list and a few data extensions with the following attributes: All Subscribers => Subscrber Key, Email Address, First Name, Last ...
2
votes
1answer
94 views

Safely refactoring public methods in apex classes

True or False: When refactoring legacy methods (e.g. adding a parameter or deleting altogether), it is guaranteed not to break anything as long as I update every reference in the code base, based on ...
3
votes
3answers
513 views

Avoid trigger trigger execution several times - Best Practices [closed]

I've been looking for a while for best practices when trying to avoid recursive trigger execution, but I haven't really found anything that I like. At the moment, the most straight forward solution I ...
0
votes
3answers
3k views

Using the same test setup for multiple test classes

So here's the situation, I have a lot of things that I want to test, and each of these things requires the same data to be present in the org. I was hoping to be able to use the @testSetup annotation ...
5
votes
2answers
6k views

Best practice for catching and displaying action errors in Lightning components

There are zillion of ways to handle or ignore errors thrown from actions calls in Lightning controllers. var action = cmp.get("c.controllerMethod"); action.setCallback(this, function(response) { ...
3
votes
1answer
348 views

Development Life Cycle of using GIT in salesforce. [duplicate]

I need guidance regarding the Development Life Cycle of using GIT in salesforce. How to test the latest code that I fetch from the GIT to eclipse. ?? What i'm upto this, is that, after syncing the ...
1
vote
0answers
35 views

SOQL queries directly in code base - without services [closed]

I would ask what You think about pure SOQL queries in code base, without boxing all of the into services? What are the advantages of using them directly in code, or maybe why I should avoid that? ...
1
vote
1answer
308 views

Subscriber Key Considerations when Connecting with SFDC

My organization is currently in the beginning stages of connecting our SFDC org with Marketing Cloud. One of the discussions has been around doing a rekey of our subscribers within Marketing Cloud. I ...
1
vote
1answer
400 views

Is there a better way to loop through multiple decisions / assignments?

Within my Visual Flow, I have a currency variable with a starting amount (Amount A). There is a screen which asks the user to indicate (using checkboxes) if each of three additional amounts (B,C,D) ...
2
votes
4answers
1k views

How to test a class with no methods?

How should I write test class for class that doesn't have methods, just fields and constructor? What are best practices? public SelectOption(String value, String label) { this.value = value; ...
0
votes
1answer
176 views

Create a BaseTest class with common variables and methods

I'm trying to create a class that will act like a BaseClass for my Test classes. It must include several variables, constants and methods common to my test methods. The kicker is that Test methods ...
4
votes
1answer
105 views

Best practices to follow to organize classes/pages based on app?

Currently we have multiple applications in our client org. It's hard to identify which components like Apex Classes, Visualforce Pages, etc belong to each application unless we look into each ...
15
votes
3answers
1k views

Best practice with big classes Apex

We've got this recommendation from Salesforce after an audit Class Complexity: • Refactor complex classes and methods into more manageable classes. Consider the use of Process Builder to ...
1
vote
1answer
179 views

Does this trigger have the right approach/best practices?

I built a trigger to update account owner depending on an external id value (Salesperson). If the salesperson code exists in a user then he will be the owner, if it doesn't exists or the code it's ...
0
votes
1answer
52 views

Is this trigger bullkified?

Will this trigger work for bulk processing? trigger ContactAfterInser1t on Dr_Invite__c (before insert, before update) { list<Dr_Invite__c> aList = new list<Dr_Invite__c>(); Set&...
6
votes
1answer
221 views

Bad practice to have unused trigger events in Apex trigger

I am curious if it's bad practice to have unused trigger events in your trigger signature if they're never run. For example trigger SampleTrigger on Account (before insert, after delete) { if(...
2
votes
2answers
624 views

rest apex security best practices

We've have created plenty of REST Apex classes and access them using OAuth 2.0 using Web Server Flow (consumer secret, consumer key, etc.) However, we're in the process of creating our first REST ...
31
votes
0answers
709 views

Best practices for designing and maintaining Global classes?

We've always been conservative when it comes to exposing Globals for use by extension packages or subscriber extensions, and perhaps too conservative. We're considering being more proactive wth our ...
1
vote
1answer
172 views

When merging Master Object, how to make ensure child objects are merged as well? (if possible)

In our Org, we are using Person Accounts; so Joe Smith can have preferences, for example he only wants red cars when renting. There's a duplicate Person, Joseph Smith, who of course only wants red ...