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.
352
questions
1
vote
0answers
27 views
Best practice to avoid naming collisions - lwc app
I wonder what is known best practice to deal with name collisions for salesforce lwc applications. Do we need to prefix names of classes, components, etc. with abbreviations. Unlocked package with ...
2
votes
0answers
16 views
Best Practice: How to restrict access to Communities in Sandbox environments?
We have this scenario: We have multiple sandbox environments that are used to develop and customize communities. Some communities include a public section.
Some of these sandbox communities are ...
0
votes
1answer
17 views
Case Assignment Rules running Multiple Times - Negative Impact
I have a bit of an odd question. Is there a negative impact running assignment rules on a Case object on every insert/update? We have a use case where we need to run when the user uses inline edit, ...
0
votes
1answer
20 views
In what all ways can I run a health check on my Salesforce instance?
In what all ways can I run a health check on my SF instance so that I improve the operational health of the overall instance and I minimize the technical debt. I know that we can run Salesforce ...
0
votes
1answer
19 views
is it ok to update a record based on a field even if the said field is not updated with new value?
I have a class that computes tax code for a given account and updates the tax code field with the new calculated value. Now irrespective of whether the tax code generated is different from the ...
-1
votes
1answer
32 views
Is there a best practice for the number of script activities in an automation?
I'm creating an automation that may need to have upwards of 20 script activities, in order to process 40,000+ records as there's a governor limit of 2500 in Rows.Retrieve. What's the best practice ...
0
votes
2answers
40 views
Is there a best practice on which metadata types can be directly created in Production directly?
We are moving to Copado for migrations and deployments until now we were using change sets etc.
If I have to put a governance for which metadata types can be created directly in Prod, what should be ...
3
votes
1answer
199 views
Using System.runAs in all tests - Best practice or Antipattern?
When doing functional tests I see many people also check the permissions by using System.runAs(userWithRightPermission) in most of their tests.
I see good reasons for doing this, because then you ...
0
votes
1answer
30 views
Best Practice for lookup relationship
I know that the best practice for Master Detail Relationship is 10,000 child records per parent. But there is a recomendation for lookup relationship?
1
vote
1answer
59 views
How to inject Mocks into LWC Controller AuraEnabled static methods
I have an Apex controller for an LWC, something like this:
public with sharing class MyController {
@AuraEnabled(cacheable=true)
public static string getSomething() {
try {
...
1
vote
1answer
36 views
Best practice when pushing change sets through Dev->Test->Release sandboxes [closed]
Using Changesets to migrate changes in an org with Dev sandboxes and a UAT/Test sandbox:
I've always considered it good practice to push the changes from Dev->UAT for testing and then push the same ...
0
votes
1answer
35 views
Trigger not working on Bulk records properly
**Requirement** - Requirement is to generate a random number(not sequential) for every case getting created, provided number remains unique in salesforce database. The number is then appended with ...
2
votes
1answer
43 views
Batch Start Method Best Practice: DML/Scheduling?
During some solutioning design, my team has come across some complexity around batch scheduling. In order to maintain performance, we've been asked if it is okay to schedule the follow up batch in the ...
0
votes
1answer
44 views
Is there is good way to send an email to a user after 5 minutes of inactivity on an Account?
An indeterminate number of images will be attached to Lead records.
We have a requirement that 5 minutes after the last image is attached, the Lead owner should automatically receive an email.
I've ...
0
votes
1answer
155 views
Use global variable and formula field vs get record in flow builder?
I have a question on what is best practice / more efficient way of building a flow. I need to get ~ 3 current running user fields for decisions in a flow. Currently, I'm just using formula fields ...
0
votes
1answer
34 views
What is the most elegant way to copy entire tables of salesforce data in the least destructive way possible?
The product I'm developing is going to act like acorporate backup solution at first but there are some data processing features that will be developed later that are the real focus.
Let's say I wanted ...
1
vote
1answer
27 views
Is error handling needed when working with input parameters?
I have a simple apex method that is used by an Aura Lightning component:
@AuraEnabled
public static void doSomething(String requestInfo) {
MyRequest request;
try {
request = (...
0
votes
1answer
33 views
Static code analysis issue
I have a method where I am fetching the Id from the URl and using page reference method as below.
Public test_method() {
Id = ApexPages.currentPage().getParameters().get('id');
PageReference ...
0
votes
0answers
19 views
How to write test class in decimal number to words? [duplicate]
how to write the Apex test class for decimal numbers to words? how to code coverage in class
public String getNumberTOWord(Decimal num) {
Decimal junkVal = num;
Decimal junkValPaisa = ...
0
votes
0answers
137 views
Multi-Select Picklist Alternative
I am looking into the best alternative solution for data capturing and reporting. I am trying to avoid multi-select picklists.
I want to capture at the Opportunity level:
Field1__c (that contains): A,...
0
votes
1answer
47 views
best practice: custom fields or one-to-one?
If you have custom data that is one-to-one with a standard record, what are some example circumstances where you should or should not:
create custom fields in the standard object?
create a custom ...
2
votes
1answer
110 views
One trigger per object is commonly espoused as best practice, but is that so for event triggers as well?
According to the documentation it is considered best practice to maintain a single trigger, even for Events the documentation reads:
... However, having multiple triggers on the same object isnāt a ...
0
votes
0answers
43 views
bulkify a scheduled flow
Currently i am working on a scheduled flow to update the opportunity record whenever a phone no field is there on the associated account record .the scheduled flow is taking the data on campaign ...
0
votes
4answers
172 views
Batch Jobs Best Practice: Generic or specific?
In Salesforce's Using Batch Apex document there is an example of a Batch class for deleting records:
global class BatchDelete implements Database.Batchable<sObject> {
public String query;
...
3
votes
2answers
54 views
Improving Lightning Performance - What does SFDC consider “Salesforce organization configuration issues”?
Per the following SFDC article, Salesforce indicates four main reasons for Lightning Performance Issues and page load time:
Geographical
Device
Browser
Salesforce organization configuration issues
...
1
vote
2answers
170 views
Is my after insert trigger efficient and safe to port to production?
Recently I created an after insert trigger to update a field in my sponsorship object. it works so far in sandbox and has passed the unit test that I have created and has 100% code coverage. here is ...
1
vote
1answer
43 views
Do not show standard Site pages in a Salesforce lightning community
We have set up a lightning community. When I access it at https://mycommunity.cs1.force.com/s/login, I see an Experience (Community) Builder lightning login page. But when I try something like this (...
0
votes
1answer
146 views
No SOQL in for loop
Re-factoring this below code to avoid SOQL in for loop. In this case below soql is for different object than the object passed in param. The solution I am trying needs for loop inside for loop, wonder ...
0
votes
1answer
44 views
Delete Salesforce Standard force.com pages and classes
We are in the process of cleaning up our code (updating to latest versions, removing unnecessary code....) and we found many force.com standard pages and classes that we are not using. Can any one ...
16
votes
5answers
7k views
When do we really need try/catch?
I know about 'always in DML operations'. But for what? What do we get? The code will crash anyway, and we can find the error in logs even without this construction. What's the main point of try/catch? ...
1
vote
0answers
165 views
Validation Rule on Lead Conversion - Best Practice
I have a Validation Rule on the Lead Object, to prevent the users from converting a Lead without filling in certain fields. The Validation works, but I want now to only requests those fields, if the ...
3
votes
2answers
822 views
Best Practice deserialize a JSON to avoid heap size limit
I'm sending an HTTP request to get a JSON of Students. The JSON is a complex JSON with arrays and its break into 3 objects in Salesforce.
I'm using a class (JSON2APEX) to deserialize the JSON.
Some ...
1
vote
1answer
178 views
How to query multiple object records without using soql within a for loop
I have a
Map<String, String> objectNameWithQueryString;
objectNameWithQueryString consists of 'ObjectAPIName' as the key and a 'soql query string as the value'.
My requirement is to perform ...
7
votes
1answer
175 views
Packaged Case Trigger fails for users without license
My managed package contains a trigger for Cases. When users have no license an Apex batch class called from that trigger fails with
First error: Insufficient user privileges
My initial assumption ...
0
votes
1answer
30 views
user training enviroment
We're in the process of researching how to setup a user training environment. We're currently doing user training in the production org, and want to get a away from that. We've got over 2,500 users so ...
0
votes
1answer
38 views
Service Cloud Automation
I have been having real trouble managing Automation in my org. I am the sole admin, with 20 users, around 5-10 are dedicated users managing around 3000 cases per month. Almost all come from Email To ...
2
votes
1answer
250 views
What is the correct way to return validation errors from a lightning Apex controller?
What is the correct approach to return validation errors from lightning controller?
Suppose we have an aura method that takes some parameters. We need to validate these parameters in order to make ...
13
votes
5answers
2k views
Should trigger handlers be static or non-static?
For a generic trigger, are there circumstances where one of the following patterns is better than the other?
trigger ObjectTrigger on Object (after event) {
ObjectTriggerHandler oth = new ...
0
votes
2answers
48 views
Benefit of actually excluding records with logic directly in Trigger vs. TriggerHandler
Is there any performance benefit of excluding records in logic directly in the trigger to avoid instantiating another class (TriggerHandler) that would essentially do the same thing? I know best ...
4
votes
1answer
2k views
LWC best Practice to call parent and child component
My question is bit difficult to explain but still I tried my best to explain it in the below playground
Playground
In my LWC project I have 3 step process and I divided it into 3 lwc pages
parent
...
0
votes
3answers
151 views
Clean code way to process a list of objects
Letās say you have a list of Accounts and you want to populate their birthday with the same date. However, you also want this method to be reusable.
What is the best way to do this in APEX?
So far ...
3
votes
1answer
90 views
How to avoid hardcoding of page name in lightning:navigation?
I need to generate a page URL and use it a link to my page. Users can click on that link and go to the page.
controller
getPageUrl: function (component) {
const navService = component.find(...
4
votes
1answer
995 views
Normalizing Boolean values in LWC
Looking at LWC e-bikes sample gallery, I found these comments in code regaring normalizing values. Can someone refer to what they have meant or how to do this normalization using best practices?
...
5
votes
1answer
158 views
LWC Event Best Practices Question
I'm confused about what documentation says about event best practices.
CustomEvent.detail
To communicate data to elements in the same shadow tree, donāt add
myProperty into event.detail. The ...
1
vote
1answer
860 views
LWC & Aura Coding Standards
I want to ask if somewhere I can find best practices how to develop in LWC and Aura? Salesforce has prepare that kind of document for Apex:
https://developer.salesforce.com/page/...
0
votes
1answer
139 views
Identifying Inactive Contacts
My question is not about how to deal with inactive contacts, but it is about how to identify inactive contacts.
Our Org has 300k Contacts, about 50% of these are obsolete.
I have created a check ...
1
vote
2answers
60 views
Best Practice: dependency on data model names [closed]
BACKGROUND
I need to display some data from another system on a lightning component. Let's say I get a JSON string from the external system as following:
{
"initialStatus": "Active",
"name": "...
8
votes
2answers
2k views
lwc dataservice architecture best practices
While developing lwc components and lightning apps I always run into this design dilemma: When I have two children components that uses the same set of source data but in different forms what is the ...
4
votes
1answer
514 views
Whitelisting Salesforce IP In External Systems
I want to integrate with an external system.
They need to whitelist my IP for permission to use their services.
I looked at this post: https://help.salesforce.com/articleView?id=000321501&type=1&...
3
votes
0answers
308 views
Is usage of console.log/console.error in production code considered as bad/good practice?
Well I've seen a lot of code examples provided by Salesforce. In one blog post - Error Handling Best Practices for Lightning and Apex - they are using console.error to report errors on ui. They also ...