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
0 votes
1 answer
18 views

Is pushing all changes on one branch on Git a great idea?

We didn't use much Git during development and we created multiple functionalities. Is pushing all changes on one branch a great idea or should we create one branch for every feature? Advantages: we ...
user avatar
3 votes
2 answers
142 views

What do I have to do in this case: List<Sobject> or Sobject?

I am beginner in Salesforce and I have to verify if the field Order.ShippingCountry is filled using the OrderId. I would like to reuse this method below to fetch the Order.ShippingCountry. But I was ...
user avatar
  • 79
2 votes
0 answers
41 views

How to handle triggers with dependent objects?

I have a problem regarding triggers on objects that effect other objects. When a Contact is saved on Salesforce, in my case it also saves an Affiliation. I have a trigger on each object that when ...
user avatar
0 votes
1 answer
64 views

Why have service classes? (Service Layer Model)

tl;dr - What are the advantages of having handler and service methods separate housed in separate classes, rather than joined in a single class. Background Salesforce and others reference using ...
user avatar
  • 601
0 votes
1 answer
43 views

What are the best practices for wsdl2apex and SOAP callouts from Salesforce

I wonder, what are the best practices I should apply when I need to integrate Salesforce with an external SOAP webservice? First of all - Apex class names generated with wsdl2apex have names which ...
user avatar
  • 635
-1 votes
1 answer
59 views

Is hard coding custom metadata type name in Apex a good practice?

I am new to custom metadata types (CMDT). With the Winter'22 maintenance, I learned that there is no longer a need to write Salesforce Object Query Language (SOQL) to access custom metadata records in ...
user avatar
  • 35
1 vote
1 answer
191 views

How to share lwc modules as reusable utility components

So I am looking to implement reusability pattern across Lwc's using utility components. What Im not understanding is limitations of importing modules/dependencies like ShowToastEvent. If I create a ...
user avatar
  • 1,687
6 votes
2 answers
282 views

SOQL query performance with many or few fields

I have a doubt. Sometimes the developer repeats many queries in different places, but what changes is the number of fields. I sometimes think about centralizing queries, but queries can have fields ...
user avatar
  • 111
1 vote
3 answers
102 views

@testSetup best practice

I'm trying to understand something so I can use @testSetup annotation wisely. As i read here: https://developer.salesforce.com/docs/atlas.en-us.202.0.apexcode.meta/apexcode/...
user avatar
  • 45
2 votes
3 answers
368 views

How to prevent accidental config changes made directly in Production?

Too many times we've had developers (as well as our release manager, who also dev's) inadvertently make a change directly in Production because they had the Prod org open alongside their dev org in ...
user avatar
0 votes
1 answer
25 views

Count of RelatedLIsts on a Page Layout

Using Tooling API, or Reports, is there a way to find how many related lists are on each Page Layout ? I am dealing with a large Org with more than 600 Objects, and some objects have more than 100 ...
user avatar
0 votes
1 answer
145 views

Salesforce Marketing Cloud : How to ensure SMS are sent to only those Phone numbers which are present in the sendable Data Extension

I have a sendable DE, which has a Phone and a locale field. I want to send SMS to only the numbers that are present in the Data extension. The last time I tried to send the SMS to the contacts present ...
user avatar
5 votes
2 answers
175 views

Best Practice and Security Question: Send Salesforce record Id to external Systems

This may sound a silly question but i just wanna be sure i am following the best practices. I have to integrate with some systems for Accounts, Cases, etc. Salesforce is the master system and after a ...
user avatar
2 votes
2 answers
178 views

Reasons to Use More Than One Profile in an Org

I just started a project at a new company who is configuring a new Salesforce org. I've learned that they are planning on using only one Profile for what currently looks like 3 different personas (...
user avatar
0 votes
2 answers
209 views

How can I write Apex Classes that share the same name as Standard or Custom objects? Is this even recommended?

I'm working on a third-party API integration and whilst modeling the relationship between classes and objects, I hit a roadblock. I need to write Apex classes that have the same namespace as standard ...
user avatar
0 votes
1 answer
40 views

Will the use of apex:actionFunction result in a CSRF vulnerability?

I need the record to be updated when the visualforce page loads. In the apex:page tag, I utilised the action property to invoke the apex method that executes update DML. Salesforce considers an onload ...
user avatar
  • 1
2 votes
2 answers
58 views

Best practice for migrating from same-record update Process Builders/Workflows to before-save Flows

First there was Workflow, and we built separate workflows for each process/action on an Object. Then there was Process Builder and Flow, and we were advised as a best practice to create a single ...
user avatar
0 votes
2 answers
614 views

Structural Question - Record Triggered flow and Apex Trigger Together?

This is a general question and i would like an opinion from the experts. I have to do something on Account that is too simple and can be achieved with the use of record-triggered flow. However, we ...
user avatar
0 votes
0 answers
18 views

Preventing Hourly Automated Emails from sending if no subscribers are on the list [duplicate]

Currently have inherited an automated email series that runs hourly that is sending 14 different emails after running a query that usually goes to zero recipients. A filter is also being used to ...
user avatar
0 votes
1 answer
41 views

Apex: Where is a good/recommended place to store custom error messages?

In order to avoid creating duplicate string literals (the error messages) in both the class that would, for example, throw an exception and its corresponding test class, where is a good/recommended ...
user avatar
6 votes
2 answers
428 views

Best practises with Lightning Message Service

As an ISV, I need to establish communication between LWC and Visualforce page. I am planning to leverage LMS and I have 2 questions: Which are the best practices regarding Lightning Message Channels? ...
user avatar
7 votes
0 answers
211 views

Best practice for establishing Salesforce as a public and secure webhook endpoint target?

We are looking at setting up our Salesforce org as a public and secure endpoint target for a 3rd party application (Housecall Pro) which will be sending us webhook calls. The only rub is they cannot ...
user avatar
4 votes
2 answers
402 views

One or multiple triggers for a generic Platform Event?

Do Trigger Best Practises still apply with Platform Events? With Custom Object triggers there are established rules, like: Have only one trigger per Object Have no logic in the trigger. Instead, ...
user avatar
0 votes
1 answer
53 views

How to avoid for loop and use map or some other technique for below logic [duplicate]

I have below code ,but not able to understand how i can avoid second for loop inside account please suggest public static void getOpenCaseOnAccount() { Map<id,user> userIds = new map<...
user avatar
  • 7
8 votes
1 answer
419 views

"Traditional" Trigger Frameworks vs Dynamic Metadata Trigger Frameworks

I'm all too familiar with the Kevin O'Hara trigger framework and have used it as a base framework in many projects before. However, I've recently been doing some in-depth reading about the idea of ...
user avatar
4 votes
1 answer
187 views

Minified code in LWC is wrong because of optional chaining operator

I have a LWC that has a simple getter function that controls whether to display an element or not: get _isGridNotEmpty(){ return this._gridData?.length > 0; } However I found that the element ...
user avatar
  • 334
0 votes
0 answers
188 views

How to avoid hardcoding the URL in Apex class

I wrote this code looking at references and documentation. However, I want to prevent hardcoding of the URl . Also, the email that I receive goes to my company's junk mail box. What best practice can ...
user avatar
0 votes
1 answer
52 views

Validation Rule Best Practise [closed]

I would like to know the best practice while creating a validation rule in Salesforce. Whether we need to split it down as much as we can(so that it's easier to understand and could give specific ...
user avatar
4 votes
1 answer
803 views

Why Import Fields Instead of Use Text in LWC?

In the salesforce trailhead "Lightning Web Components and Salesforce Data: Use Apex to Work with Data" we have the following code: import { LightningElement, wire } from "lwc"; ...
user avatar
  • 601
8 votes
1 answer
1k views

Why Declare Variables Outside of LWC Class

In the salesforce trailhead "Lightning Web Components and Salesforce Data: Use Apex to Work with Data" we have the following code: import { LightningElement, wire } from "lwc"; ...
user avatar
  • 601
1 vote
0 answers
91 views

How to handle deep links without CSRF tokens gracefully?

CSRF protection is mandatory now, and we have enabled it on our public site successfully, but as this previous answer notes, plain links (such as emailed URLs or bookmarks) to protected pages don't ...
user avatar
  • 303
0 votes
0 answers
99 views

Best Practice: Using Id or Name in Filter Criteria and Formula Fields

We're working in an Org that uses Ids in Filter Criteria and Formula Fields to dictate logic based on Record Types. When you refresh a sandbox, it maps the correct Id to the correct record type id and ...
user avatar
1 vote
0 answers
93 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 ...
user avatar
  • 635
2 votes
0 answers
79 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 ...
user avatar
  • 942
0 votes
1 answer
114 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, ...
user avatar
  • 765
0 votes
1 answer
35 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 ...
user avatar
  • 2,052
0 votes
1 answer
20 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 ...
user avatar
  • 456
-1 votes
1 answer
41 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 ...
user avatar
1 vote
2 answers
116 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 ...
user avatar
  • 2,052
3 votes
1 answer
425 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 ...
user avatar
0 votes
1 answer
86 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?
user avatar
2 votes
1 answer
292 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 { ...
user avatar
  • 8,213
1 vote
1 answer
109 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 ...
user avatar
  • 11
0 votes
1 answer
70 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 ...
user avatar
  • 19
2 votes
1 answer
175 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 ...
user avatar
  • 142k
0 votes
1 answer
111 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 ...
user avatar
0 votes
1 answer
492 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 ...
user avatar
0 votes
1 answer
74 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 ...
user avatar
  • 1
2 votes
1 answer
39 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 = (...
user avatar
  • 4,645
0 votes
1 answer
131 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 ...
user avatar

1
2 3 4 5
8