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
0 answers
24 views

Use "Business Hours" on a custom process?

I have the following requirement: From 8AM to 5PM i should add X value to some lead's custom field this should happen to new leads being inserted, any insertion outside of that range should not be ...
Giovanni's user avatar
-1 votes
1 answer
17 views

Are there any risks to creating custom fields on a Salesforce custom object from a managed package?

I've created custom fields on a custom object in my org that came with Agile Accelerator. I want to know if there are any downsides to doing this. My largest fear would be updating the package and it ...
AbbyVS's user avatar
  • 3
2 votes
1 answer
60 views

Best Practices for CRUD/FLS/SHARING checks in unmanaged code

I'm auditing an ORGS unmanaged Apex and trying to form a concrete framework for when I care about PMD warning for ApexCRUDViolation & ApexSharingViolations. It's always been my understanding that ...
NSjonas's user avatar
  • 10k
1 vote
1 answer
68 views

trigger to update parent record without sub-query

suggestion required: Below trigger updates a parent record (an Account) fields based on changes to its related child records (Opportunities). The trigger works well and updates the parent record ...
Gaurav kumar's user avatar
2 votes
3 answers
700 views

How to avoid if-else/switch chains and preserve open/closed principle in Calculator program (apex) [Solution: Strategy Pattern]

TL;DR In apex, is it possible to get around the use of if-else/switch statements to supply unique code via an enum or other parameter? Something like storing functions or class instances in maps or ...
Jwok's user avatar
  • 757
0 votes
0 answers
42 views

Best practice for deleting One Time Batch Jobs

As you know there is a common case like data cleanup and data migration or even the case when we add new field which should be populated on new records and we need to populate it on all existing ...
Dmitriy Yurkin's user avatar
1 vote
3 answers
466 views

Where does the colon (:) belong in the Apex SOQL query - to the operator or the variable?

I'm asking about a best practice - Salesforce gives us freedom here but we'd like to establish some sort of consistency in our team. Similar to the case size - although Apex is case-insensitive, it's ...
Przemysław Długoszewski-Tamoń's user avatar
3 votes
3 answers
193 views

Should be Triggers inactive by default in Unit Tests?

Apex Triggers can cause problems when developers need to create test data. This is because triggers can execute a lot of logic, such as validation, API callouts, and multiple SOQL and DML statements (...
Piotr Gajek's user avatar
  • 2,422
0 votes
1 answer
39 views

Is it best practice to have separate apps for different teams within an organisation?

This is a super basic question, so apologies if this is the wrong platform. My experience is largely with platforms like Zendesk and Kayako and have done a bunch of learning through Trailhead, however ...
Mike.A's user avatar
  • 3
1 vote
2 answers
255 views

How to populate wrapper's properties?

The question is about the best practices when working with the Wrapper class. Assumptions We have PersonWrapper. public class PersonWrapper { private String id; private String firstName; ...
Piotr Gajek's user avatar
  • 2,422
0 votes
1 answer
32 views

Custom Aura Components Throwing Errors in Builder - Best Practices

We are using custom Aura components in our Lightning Community and these components like most, respond to whomever is logged into the Lightning Community and populate themselves with relevant data. My ...
Slinky's user avatar
  • 135
0 votes
1 answer
59 views

CODE BEST PRACTICE - Calling the custom metadata check from every method in Trigger

I had previously asked how to write test class to cover custom metadata in Test class coverage required for Custom metadata that turns a Trigger on and Off and found solution from the answers. As a ...
Abhinandana 's user avatar
1 vote
1 answer
139 views

Best practices Use == or isSameDay apex date

Currently in production I check if two dates are identical in apex by doing date1 == date2 I see in the documentation that there is also isSameDay Would you know if using == between two dates is a ...
arnaud's user avatar
  • 104
0 votes
1 answer
172 views

Is it considered bad practice to have Cases permanently owned by a Queue?

I am using Salesforce for Case Management. I have quite a number of queues (about 250) set up for my various teams and I need all members of a queue to continue viewing cases even after a specific ...
JustinF's user avatar
  • 391
1 vote
1 answer
136 views

Why are unused imports bad in LWC?

For Ex, if I use uiRecordApi and import getrecord but never used that, why is this a bad practise? Does it affect performance, script load times etc?
Apex Srinivas's user avatar
1 vote
1 answer
91 views

Dynamic SOQL inside for loop

We have some legacy code in one of Salesforce orgs. While going through code, I encountered this piece of code List<query_metadata__c> dyQueries=[select id,query__c,object__c from ...
Amit Rajput 's user avatar
0 votes
1 answer
57 views

Best practices for managing Github during Salesforce Releases?

My team is working on a project that will likely take over 6 months. We are making edits to Site pages, classes, fields, flows, etc. Part of this process involves staging changes in a partial sandbox ...
AMtrying's user avatar
2 votes
1 answer
3k views

Salesforce Scheduled flow bulkification best practice/ clarity

I have a question about bulkifying scheduled flows. When you create one you have two options. Use a get element to grab the records you want or set an object & conditions. I've found the ...
Thomas Gunn's user avatar
-2 votes
1 answer
125 views

Mass Contact Merge in Apex

I am trying to implement Mass merge of contacts in apex, Like uploading a CSV of multiple records which has would have details like retainable ID , duplicate contact Id etc., now I need to traverse ...
Kishore's user avatar
1 vote
1 answer
162 views

prefix Phone field, different Objects

I have a method in beforeInsert trigger, when new SObject is inserted it should add a numeric prefix. That alone is working, but my assignment now is make it much shorter. Currently I'm having 1 block ...
jur1s77's user avatar
  • 47
1 vote
3 answers
375 views

Which way efficiently fill a map

In a certain scenario I need to fill a Map<Id, List<...>> In our example let's say All the contacts linked to their accountId (Map<Id,List> contactsPerAccountId) I'm asking myself ...
Yaac0's user avatar
  • 155
0 votes
3 answers
2k views

Best practice: formula field in child record to reference parent field

I found this question Best Practice: Formula field Vs new (duplicate) field but it's a bit old and it didn't get much traction anyway. I have a field Minion__c in the parent record and I need a field ...
Arepa Slayer's user avatar
1 vote
0 answers
303 views

Is there a design pattern for structuring Record Triggered Flows?

Whilst reviewing The Ultimate Guide to Flow Best Practices and Standards from Salesforce, I saw no mention of any design patterns or best practices on how to handle structuring Record Triggered Flows ...
Swisher Sweet's user avatar
0 votes
0 answers
107 views

What are the benefits of the internal Platform integration with using Platform Events?

I'm learning about the Event-driven Architecture from Trailhead, this unit to be exact: Understand Event-Driven Software Architecture. As in general I can say that the concept is pretty clear to me (...
Przemysław Długoszewski-Tamoń's user avatar
0 votes
2 answers
270 views

Best practice for async apex classes (Queueable, Batchable) in relation to service classes

When creating async apex classes (e.g. Batcheable, Queueable), especially classes associated with specific SObjects, what might be the best practice for where these async classes should be housed. ...
Jwok's user avatar
  • 757
0 votes
1 answer
509 views

Platform event Fired from two objects

We are planning to build a platform event, which should publish changes from two objects. Consider there is an insert/update of records in Account object or Customer__c object. We need to insert/...
SFDC_Admin's user avatar
0 votes
1 answer
91 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 ...
NonameJavaNoob's user avatar
3 votes
2 answers
264 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 ...
Cline's user avatar
  • 91
2 votes
0 answers
96 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 ...
Patrick Packham's user avatar
0 votes
1 answer
743 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 ...
Jwok's user avatar
  • 757
0 votes
1 answer
133 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 ...
Grzegorz Połuch's user avatar
-1 votes
1 answer
284 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 ...
Naven's user avatar
  • 45
1 vote
1 answer
1k 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 ...
CloudHugger's user avatar
  • 1,709
6 votes
2 answers
753 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 ...
dsd's user avatar
  • 121
1 vote
3 answers
1k 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/...
Benj's user avatar
  • 45
2 votes
3 answers
813 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 ...
Brent Bowers's user avatar
  • 3,064
0 votes
1 answer
198 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 ...
GroundToCloud's user avatar
0 votes
1 answer
956 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 ...
Neeraj Kulkarni's user avatar
5 votes
2 answers
529 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 ...
Giorgos Galaios's user avatar
2 votes
2 answers
579 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 (...
Bob Mount's user avatar
0 votes
2 answers
748 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 ...
Ricky Viejo's user avatar
0 votes
1 answer
171 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 ...
Shine's user avatar
  • 1
2 votes
2 answers
270 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 ...
Morgan Marchese's user avatar
1 vote
2 answers
3k 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 ...
Giorgos Galaios's user avatar
0 votes
1 answer
188 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 ...
Giovanni's user avatar
6 votes
2 answers
1k 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? ...
Gabriel Serrano Salas's user avatar
9 votes
0 answers
555 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 ...
Swisher Sweet's user avatar
4 votes
2 answers
951 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, ...
Robert Sösemann's user avatar
0 votes
1 answer
805 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<...
Sandy's user avatar
  • 7
8 votes
1 answer
988 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 ...
Morgan Marchese's user avatar

1
2 3 4 5
9