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

learn more… | top users | synonyms

0
votes
1answer
17 views

Error Logging versus Showing Error to User

What is a better strategy when writing apex or visualforce code, with respect to error logging? Show errors occurred to end user (OR) silently log them to a custom object (OR) both of the above
1
vote
2answers
42 views

best practice for object initialization

What is the best approach from below two for initializing an object instance while creation in a loop. for(string str: stringList){ //create obj records ...
0
votes
3answers
27 views

how to to rollup the field for custom object? [closed]

i am having 1 custom object capital adjustment with a field name tax. i want to roll up this tax value to another custom object contact(i cant able to look up with the capital adjustment). please ...
0
votes
1answer
29 views

Best Practice: Formula field Vs new (duplicate) field

I have custom object with Lookup to contact and need few fields in custom object which are already present in Contact. Is it good to create formula field in custom object or create a same field and ...
0
votes
1answer
27 views

How can I display string returned by a Apex class method on VisualForce pages?

I have written the following Apex class. Now, I wish to display the string returned by getMonthsString() on VisualForce Pages. Here is the Apex class: public class MyFirstClass { public static ...
3
votes
2answers
59 views

Building Dynamic Test Classes that don't break due to Destination Org's - validation rules or Required Field settings

Scenario: I have built a solution for a Customer and I have used Apex for this solution.The deployment went well. But after few months the customer added some validation rules to the Sobject and when ...
0
votes
0answers
19 views

How to replicate PageReference functionality in Lightning

I have a VFP that adds OpportunityLineItems. When the user clicks on the [Save] button, the OLI is saved and the user returned to the Opportunity. In Lightning Experience this takes the user back to ...
19
votes
3answers
223 views

Why Are Data Silos Important in Unit Tests?

I have a lot of strong opinions about this issue, but had a hard time finding official documents today to back up my position. A lot of times we say it is bad practice to use seeAllData=true, but we ...
2
votes
1answer
31 views

Communication between two Managed Packages

We have two managed packages. Is there a possibility to let the two packages communicate within one org? I've seen for example this article, but I was curious if there is any other possibility and a ...
4
votes
2answers
168 views

DOM manipulation using External libraries in lightning component

As per the LC documentation and answers to the below questions: 1.Jquery selector is not working properly in subsequent loads in lightning component. 2.DOM modification feasibility in lightning. It'...
0
votes
1answer
65 views

bestpractice for calling apex methods

I have a class that calls to an apex method with in a for loop and that method in-turn calls other apex method. All the methods have SOQL's in them. Running into 101 SOQL issue. for(sobject obj:...
3
votes
1answer
34 views

Governor limit on trigger clarification

If I have a below loop: List<id> var2=new List<id>(); for(Sobject1 s:trigger.new){ var2.add(s.Sobject2); for(Sobject2 var: [select Sobject2 from Sobject where Id IN:var2){ //do something ...
1
vote
2answers
37 views

Writting efficient trigger way

I have the below piece of code: List<Job_Opening_Skill_Set__c> jobopening= [ Select id,Job_Opening__c from Job_Opening_Skill_Set__c WHERE ID IN:trigger.newMap.keyset()]; Map<Id, ...
1
vote
2answers
46 views

Too Many SOQL Queries: 101 - trigger

I am getting error message and I believe it to be error with this trigger. I am new to coding and this was done previously so any assistance is greatly appreciated trigger setAttendeeNumbers on ...
24
votes
2answers
2k views

Why Would I Not Enable Chaining?

The Apex Design Patterns is an awesome resource, and I learned many tricks from it. One of my favorites is method chaining, and I quickly developed an axiom: Any time you would return void, return ...
2
votes
1answer
45 views

AggregateResult Use Case Best Practice

Trying to determine best scenarios for using AggregateResult e.g. Versus using a for loop gathering totals with += or similar syntax.
0
votes
0answers
21 views

Best Practices for Salesforce [duplicate]

I am new to salesforce,i am from java background. Could you please guide me where can i find best practices for writing apex,batch,triggers I have already gone through David Liu tutorials. I am ...
6
votes
1answer
115 views

What is a good and free static apex code review plugin for IDEA, eclipse and ANT?

Java has a number of useful and FREE tools for reviewing not just formatting and style but quality of code and bad coding habits. Checkmarx and Code scan could work but they are not free and open ...
3
votes
1answer
60 views

Querying / Managing Queries with Multiple Permutations

I'm writing a class to implement Support.EmailTemplateSelector. To retrieve the correct email template, I'm querying a Custom Metadata Type Smart_Template_Loader_Conf__mdt, retrieving an ...
5
votes
3answers
99 views

Trigger bulkification when adding errors

Snippet 1: trigger AccountValidationTrigger on Account(before update){ for(Account accObj: Trigger.new){ if(accObj.Some_Flag__c != TRUE){ accObj.addError('Some flag should be true');...
3
votes
1answer
59 views

Converting/Parsing an Enumeration to a String More Generically

This is an extension of an earlier question I made. So, using the answer from the previous question I mentioned, I am able to make a generic utility that would convert/parse an Enumeration to a ...
1
vote
1answer
30 views

Modeling Abandoned Cart on Orders or Opportunities [closed]

I'd like to begin modeling abandoned carts inside our org. We can reliably push in data from the cart on our ecommerce platform at various stages throughout the checkout process, email the customer ...
21
votes
2answers
399 views

When To Use Set vs. List In SOQL

I have always assumed that it is better to use a Set in my query filters instead of a List. For example: Set<Id> parentIds = generateParentIds(); List<Child__c> children = [SELECT Id FROM ...
5
votes
6answers
254 views

Is it a good practice to skip queries with empty conditions?

I am wondering if it's a good practice to skip queries when there's nothing in 'where' clause, especially in triggers. Like: if (idList.size() > 0) res = [select id from Case where id in :...
0
votes
1answer
36 views

System.LimitException: Too many SOQL queries: 101 & CPU time exceeded

I am getting the following two errors in various scenarios of running an apex class 1) Too many SOQL queries 2) CPU time exceeded The following is the only method in my controller class for ...
3
votes
4answers
138 views

Best Practice for Sending Emails via Apex

I'm playing around in my Dev org and am using a trigger to send a basic e-mail to System Admins when an account is created as follows: private static void doNotifyAdmin(List<Account> acc) { ...
1
vote
1answer
113 views

Best Practices for generating large XML files

I currently have some requirements for an integration that I am doing and was curious if anyone had some feedback on the best initial approach. I am currently working on building out the structure ...
0
votes
2answers
38 views

Best practices for bulk updating old data

I have a new trigger that fires whenever I add/update a Contact. Let's say it calls a method in class which sets the Contact's X1337_Name__c field to a l33t h4X0r3d (that is, 'leet haxored') version ...
7
votes
1answer
147 views

Best Practice: Refresh Cadence

Background We have a fairly straightforward org structure: Our Stage environment is a Full Sandbox. All sandboxes downstream of that are Developer Pro. We added the SubDev sandboxes very recently ...
2
votes
2answers
99 views

Avoid Multiple Triggers in Managed Object

Is there any official best practice, approach, recommendation, solution, work around, etc. for the scenario were we would want to extend a managed trigger actions? This topic has been discuss in some ...
0
votes
1answer
26 views

Formula for Picklist with If Conditions

I have 1 pick-list called Ward Types. Ward Type items are, Suite Deluxe Special AC Semi Private General Ward I want the formula for if(WardType__c == 'Suite') { Amount__c = 500; } if(...
1
vote
1answer
31 views

How to handle multiple input/output tags with the same fields in VisualForce

I have created a VisualForce page that is basically a wall of inputFields. I had a requirement to make all of the inputFields into outputFields when a certain event happens (the event happens, all ...
3
votes
2answers
249 views

Is this an abuse of ternary operator and inline SOQL or is this acceptable?

I have written a function like the one below to check if there is atleast one occurrence of a given Id in either of the two objects. I am having doubts on if I should use an if branch or use a ternary ...
2
votes
2answers
50 views

Best practice for testing VF/Apex around Reports is (SeeAllData=True) + actual reports?

Here I thought the new Analytics API actually allowed us to create reports from scratch using apex. Guess not. I have a VF page and a controller extension that interacts with reports and their data ...
1
vote
0answers
56 views

Best practice for custom fields added to standard objects in Managed Package

We have a requirement wherein we need to have certain custom attributes in the Account object within our Managed Package being deployed onto an existing SFDC set up. These attributes are readable and ...
0
votes
1answer
59 views

Use IF vs Else If Statements

I have the following code (which works just fine) but am curious as to the structure of it regarding my If statements. I suppose I could be using IF-Else Statements but am not sure why that would be ...
0
votes
2answers
246 views

Test class coverage issue?

I had written test class for below apex class, but still it's showing 66% coverage. in the apex class public String[] LeadItems { method get method is covered, but set is not covered? How to ...
4
votes
2answers
235 views

Avoid Hardcoding Of UserId's in Apex

In one of the triggers, they have hard coded the userid, as below. How can we avoid this? if(currentUser != '012300000012345PPPP' && Utils.isS == false) { //DO ...
0
votes
2answers
35 views

Account field clean up best practice - how long to hold onto field before delete

We are in the process of cleaning up unused fields (generally under a 5% usage) in Accounts. The fields have been removed from the new Layouts and we are ready to deploy. How long should we hold ...
7
votes
1answer
211 views

Apex Testing Chaos

I did a "Run All Tests" in production instance and found out that the following. a) Code coverage of all the classes is 76 % b) 160 Test class failures are shown (101 from apex test classes and the ...
0
votes
1answer
79 views

Best practices for schedulable class

I have a custom object called Lease_Reminder. The object has a couple of fields on it, including Status_Alert and Effective_Date. As today gets closer to the Effective_Date, the Status_Alert needs ...
1
vote
2answers
80 views

What is the best practice when creating enterprise custom apps?

We are new to Salesforce and only recently we started actually discussing using Salesforce to support some of our more complex business operations. The use of Salesforce to support these business ...
1
vote
2answers
74 views

Login Security for Integrated Applications

Let's say you have a system that you want to integrate with Salesforce. You create a new user for the system, set up a trusted ip range, make the profile an API-only user, and then give the username ...
0
votes
4answers
1k views

Updating a field with a value from parent during insert trigger

I would appreciate some best practice advice here - I have an insert trigger to populate a field in the record being inserted into a custom object with the value of a field in the parent object. ...
4
votes
1answer
154 views

Bulk data API: How to Avoid Upserts

I'm working on an daily integration of about 5 million records (file delta's is not an option). Best practices for large data volumes recommends avoiding upserts. The only alternative solution I can ...
5
votes
2answers
165 views

Apex trigger - is this the best approach?

I'm getting up to speed with Apex - I have written a trigger that works, but is this the approach that an experienced coder would take? I have a custom object (vist_detail__c) which has a lookup to ...
1
vote
1answer
456 views

Retrieving & Updating record related by Junction Object with single SOQL query

I've written the below Trigger to update Opportunities with a date value from MPM4_BASE__Milestone1_Project__crecords. The two objects have a many to many relationship and are related by ...
0
votes
1answer
422 views

Exacttarget - Sending email to filters VS sending email to filtered data extension

I would like to send emails to a group of subscribers. I would like to filter them from the data extension subscriver_all, where all my subscribers are. From what I know there are two ways of doing ...
11
votes
4answers
401 views

Archiving Data to Heroku

Ok after hours of searching I cannot believe that something that would seem like an every day need does not have any videos, tutorials, etc directly related to it. Heroku is tough for me as it seems ...
3
votes
1answer
124 views

Javascript Remoting vs Consuming Web Service

I am accessing a service side function through a javascript button on a visualforce page and I wanted to know; what is a better solution - Javascript Remoting or the AJAX toolkit (consuming a web ...