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
vote
1answer
23 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
28 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
32 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
29 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
105 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
19 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
40 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; ...
2
votes
2answers
39 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
169 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
20 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
142 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
38 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
6k 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
83 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
207 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
71 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
134 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
25 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
27 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
50 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 ...
10
votes
4answers
1k 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
45 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
1k 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
106 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
85 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(...
3
votes
1answer
489 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
125 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
526 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
74 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 ...
0
votes
0answers
23 views

Best practice for controlling record access based on User's Country

The requirement: All Users in South Africa should only be able to edit Accounts (parent) where Country = "South Africa". They should also be able to edit all Projects (child) and Project Roles (...
1
vote
2answers
55 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
1k 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
148 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
149 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 ...
2
votes
2answers
76 views

with and without sharing with innerclass

I'm working on a project that needs to change a lot of data that the user shouldn't see in the backoffice. So I'm wondering if I should put my entire class "without sharing". For now I'm creating a "...
1
vote
1answer
121 views

Best practice for a query inside a batch and Mapping

I'm working on a batch which getting a params from another batch in the finish method. The Params are : A Map - Map<Sobject,Set<String>> A Set - Set<String> I lost the values of ...
3
votes
3answers
450 views

Batch - Sending data from one batch to another

I having a little issue to understand the concept of passing params via batches. I have two batches which I would like to send data between them. Batch A creates a Map<sObject,Set<String>&...
2
votes
1answer
73 views

Get component value directly

This is a general question aimed at finding best approach to do some task. Now I interested in how should I get values from inputs in lightning components. Let's say I have a component: Example.cmp &...
3
votes
1answer
390 views

How should I schedule multiple job of the same class?

I need to have a job that runs every 15 minutes. I checked out the documentation for Apex Scheduler and I came up with two solutions: 1-st: ScheduledJob job = new ScheduledJob(); System.schedule('...
1
vote
0answers
37 views

Bulk Job Status - Failed vs Not Processed?

What are the use cases for setting a Bulk (version 1) job to a status of Failed vs Not Processed? Salesforce documentation gives the same description for both The batch failed to process the full ...
10
votes
1answer
486 views

Most efficient way to switch on SObjectType?

It is a bit odd we can't evaluate a switch statement directly on SObjectType, so I am trying to determine conclusively which workaround is the most efficient. Just to verify, I tried to compile this ...
2
votes
1answer
100 views

Enterprise Patterns for Consuming non-trivial REST services in Apex [closed]

Communication from Apex with huge REST Apis feels cumbersome to me as there is so much repetitive work involved with building Apex Objects that function as callout request params or responses. This ...
0
votes
0answers
50 views

best practice to find the duplicate contact using apex trigger (not using duplicate rules)

I am using the below handler class in contact trigger to find the duplicate contacts, it checks only the lastName now if I want to check more than 2 or 3 filed then the only option I have is to create ...
1
vote
2answers
116 views

Using String Object or Field Names instead of literals. Using object prefixes

Is there any benefit of getting sobject type using Schema.getGlobalDescribe().get('Lead'); instead of Lead.sObjectType; Also what is the benefit of using 3 char prefixes of known IDs like Id ...
1
vote
0answers
89 views

Validate inputs on server side

BACKGROUND I am working on a lightning component which is a simple form that takes from, to emails and a message body as user input and passes this data to an apex controller. Apex Controller ...
3
votes
3answers
127 views

Array notation for List<List<Sobject>>

In an attempt to be as byte pinching as possible(personal goal), I have a question some time on Google has not been able to answer. I did look at some Java documentation to try and resolve the issue ...
0
votes
1answer
208 views

Best approach for handling preventing Parent trigger when updated from multiple child objects

I need some suggestions in improving the 'prevent trigger' logic. I have parent 'Lead' object and couple of child objects. I have Trigger Helpers on each of these objects. When these child object ...
2
votes
1answer
106 views

Validating Apex method parameters

Is it a good practice to validate method parameters in Apex methods? In C# and Java you generally validate against nulls and throw argument exceptions to prevent usage errors. I don't seem to see that ...
2
votes
2answers
773 views

Hosting images in SFMC - is it a good idea?

In my company, we store all the images we use in our emails in a separate FTP server; an FTP we know that can handle the load. But since SFMC has the functionality of hosting images itself; that ...

1
2 3 4 5
7