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
29 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
69 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
35 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
28 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
113 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
63 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
21 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; } ...
1
vote
1answer
21 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
225 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
38 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
37 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
44 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
86 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
174 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
22 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
181 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
49 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
50 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
68 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
523 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
114 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 ...
4
votes
2answers
150 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
226 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
119 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 ...
10
votes
4answers
296 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
73 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 ...
2
votes
2answers
45 views

How to limit control flow during unit test?

I want to limit the control flow during a unit test so that it does not leave the method being tested. The unit test is for a controller method, and in that method the controller creates an object and ...
2
votes
3answers
507 views

How to test apex code that is driven by formula fields (Best Practice)?

Question Are there any best practices out there for testing apex code that is driven by formula fields so that changes to the formula field formula don't break your test? Background Good test ...
1
vote
1answer
70 views

How to deal with Activities in a Case Hierarchy?

Let's consider a Case in the service sense of the word - a caller calls up with a situation ("My printer's broken."). Now, maybe the caller calls up about more than one situation ("My printer's ...
6
votes
1answer
250 views

Salesforce - business logic - best practices

I would be really grateful if anybody could help me clarify, where to deploy business logic. I'm aware of the following possibilities: Write the main parts of the business logic in Apex Apex ...
-1
votes
1answer
836 views

How to Write a Test Class for Webservice Class?

Situation I wrote a web service class. From my understanding unit tests in salesforce are supposed to test the whole functionality (end to end). But I don't know how to test this external interface. ...
5
votes
1answer
263 views

Test Classes to Cover Multiple Triggers/Classes, or 1-to-1?

Background: My org has reached almost 750 unique un-managed classes and triggers. Until now, we had been adhering to the 1:1 test class to class school of thought. Now, we are at the point where we ...
5
votes
3answers
212 views

Should member variables be initialized inline or in the constructor?

Is there or should there be a hard and fast rule for whether to initialize a class's member variables inline vs. inside a constructor? Consider the following two approaches that I think are ...
7
votes
1answer
192 views

Considerations for calling out to enterprise applications behind a firewall from salesforce?

If I'm looking to integrate an enterprise application behind a firewall with Salesforce, what considerations should I be making? From the architect certification study guide Given a scenario, ...
2
votes
0answers
79 views

Get Chatter Group Link with URLFOR

Would like to add a link to a chatter group to a visualforce page. Following best practices was trying to use {!URLFOR()} so the page doesn't break if the chatter group url format changes. However, I ...
5
votes
2answers
136 views

Is there a more efficient way of getting an object by related list?

I've started programming in Salesforce in January 2015. Most of my code uses this methodology : : List<String> accountIds = new List<String>(); for(Account account : accounts) { ...
1
vote
2answers
57 views

Using field tooltips - What's best practice? [closed]

What's the best practice for when/if to add field help text? Should every field have help text or only the fields where the field label is not self-explanatory? Note: This is a business question, ...
11
votes
4answers
5k views

Efficiency of List.size() > 0 vs. !List.isEmpty()

Anyone have any data to support a claim for which of the following two expressions is more efficient (meaning faster)? The use case is determining whether a List is empty to inform an auxiliary method ...
7
votes
4answers
656 views

One Trigger Approach: Any Logic in Trigger?

I am getting my head around really using a single trigger approach and I appreciate that minimal logic should be in the trigger. I'm already using utility classes but I'm used to including filtering ...
2
votes
2answers
251 views

Why (seealldata=true) results into more code coverage?

I wrote a trigger to prevent more than n incidents for a client(lookup to user) at any point of time. trigger CountLimit on Incident__c (after insert,after update,after undelete) { Set<Id> ...
0
votes
2answers
414 views

Fire Trigger Only When Stages Moves to Closed Won

I have the trigger class below and I would like it to fire only when an Opportunity Stage is changed to Closed Won. Can anyone help me figure out how to do this? I have an if statement, but it fires ...
0
votes
1answer
182 views

Using Product and Pricebooks without set Product Prices

I need to see best practices for our pricing model. We have a SaaS company without a set price. All of our product pricing is dependent on the size of the company that signs up. So I'm not sure how to ...
4
votes
2answers
2k views

How do I access Custom Settings in Apex?

If I have a hierarchical custom setting: Custom_Page__c With one field: Url__c Using apex, how can I surface this field in a visualforce page? Can I just query it as if I was querying a custom ...
0
votes
1answer
79 views

Enabling Enhanced Lookups

Does anyone know of any disadvantages (or compelling reasons NOT to enable) Enhanced Lookups? I don't see any references to such information in Google and Stack Exchange searches. My knee-jerk ...
1
vote
1answer
37 views

Salesforce code kata

Personally I find the repetitive execution of some simple exercise very helpful to me: a good way to learning. Even if I'm totally ok with programming (java, javascript) I'm totally new to ...
1
vote
1answer
89 views

Best practice (UAT) testdata

I was wondering what your opinions are about UAT testdata in case there's no Full Copy Sandbox available. As far as I'm aware there's two options: Developing a testdata factory, which tries to mock ...
0
votes
2answers
71 views

Dealing with legacy data violating validation rules

In a traditional database, constraints will be applied to all data in the database. In Salesforce, however, validation rules only apply to data that has changed. As I update my schema, I also update ...
2
votes
2answers
323 views

Time-dependent workflow error handling

Question: How are errors (validation rules, addError in triggers etc.) handled by time-based workflows? And are there any best practices regarding time-based workflow error handling? Example: In my ...
1
vote
1answer
952 views

Translation, Localization and Internationalization Best Practices

There are plenty of things to keep in mind when trying to allow translation, localization and internationalization (t8n, l10n, i18n) in any framework. Salesforce has a whole infrastructure built ...
7
votes
1answer
469 views

Best practices for custom controller actions

Many times I've came across the following issue: should I use one custom controller for all the actions for some sObject or some area, or maybe there should be separate controllers for editing, ...