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
10
votes
4answers
2k 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
549 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
1k 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 ...
1
vote
2answers
1k 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 ...
7
votes
2answers
7k 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
543 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
93 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 salesforce,...
1
vote
1answer
181 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
206 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
760 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 ...
3
votes
1answer
4k 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
1k 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, ...
5
votes
1answer
86 views

Is it feasible to create a “universal join” object?

In a blog addressing the implementation of Milestones PM into an existing Org, Reid Carlberg suggests the creation of a "universal join object." In essence, this object effectively facilitates type ...
2
votes
2answers
821 views

Best Practice: Data Migration

I want to run a data migration using data-loader. I have changed the structure of my database and now I need to migrate the data. I have following questions: What is generally done in terms of ...
6
votes
2answers
3k views

What are the best practices for Triggers

My requirements are: Upon creation of Accounts there is a trigger that creates a contact with specific record type Organization Donor Proxy I wanted to create another trigger on Account after Insert/...
3
votes
3answers
2k views

trigger design pattern

I was watching some videos on apex best practises and I spotted some discrepancies in advice people give. I wonder how you people code your triggers. The recommendation is to have one trigger per ...
2
votes
1answer
83 views

Can I move this JavaScript function which VisualForce used out of the global namespace?

Currently looking at Refreshing Chart Data Using JavaScript Remoting Reading about JavaScript best practices, I came across the idea of keeping functions out of the global namespace, so I tried to ...
0
votes
1answer
67 views

Multiple File Data Set Import Cleaning

It is pre-Salesforce import, I have designed the Named Account structure inside Salesforce, and I have 1500 Hoover's D&B Family Trees with the same columns and headers in .xls form. What do I use ...
27
votes
2answers
8k views

How to set up views and navigation in Lightning?

What is the best way to create views in Lightning? And then, how would you navigate from one view to another? Conceptually I'm thinking that I'll have two components, ns:foo and ns:bar, and ...
4
votes
1answer
699 views

Generic account owner considerations - record skew - customer portal accounts?

In our organization, accounts aren't owned, and teams are used to manage sharing of accounts. We're planning on having all accounts owned by a single generic user. According to the architect resources ...
7
votes
7answers
4k views

Multiselect Picklists with many values

Note: Though this is still of use in extreme cases, the limit on multi-select picklist values has been raised to 500 values in Winter '16. Also, the Global Picklists feature, which is currently (...
4
votes
1answer
889 views

Best practices for naming unit tests [duplicate]

My organization has a mishmash of apex classes, both regular classes that execute specific business logic and test classes that execute unit tests on those regular classes. When we started developing ...
0
votes
2answers
54 views

Which code is heavy when being executed

I'm comparing records based on their dates, if the date is equal to a particular month its data goes to a particular object. Example: If this the record is in the current month then it will be saved ...
2
votes
1answer
771 views

How to hide components until data are bound in Lightning?

What is the best way to configure components or elements to be hidden until the required data binding operations have been completed in the background via Ajax? I'd like to replicate the current ...
1
vote
1answer
357 views

Why does my delete trigger cause a 'Too Many SOQL Queries' error?

I have a trigger that is supposed to see if a field is empty and, if it is empty, it is supposed to check if there is an Account Team Member with a certain role. If that is true then it is supposed to ...
3
votes
0answers
1k views

Best way to set up dependent picklists in Lightning

One common programming challenge I anticipate in Lightning is the need to set up dependent picklists. I've cobbled together one approach shown in this gist for setting up a dependent picklist, but I ...
15
votes
2answers
17k views

How to pass values across Lightning components?

What is the best way to pass, propagate or share values across Lightning components? For example, let's say I have two components ns:foo and ns:bar. Both components have the following attribute: <...
1
vote
2answers
143 views

Should all available metadata be managed in a VCS?

I'm setting up a git repository for an SFDC project across a team of developers. I think I should commit all metadata comprising the full org so we can manage changes in addition to the usual ...
3
votes
2answers
3k views

How do I test an apex trigger that sends an email

Trigger is: trigger emailtemplate on opportunity(after update) { List<opportunity> oList = Trigger.new; List<opportunity> nList = trigger.old; if(oList[0]....
1
vote
1answer
481 views

Change Contact Owner for Profile

I have a case in which a certain user with profile that should be able to transfer a contact even the contact is still not his own. I tried using the 'Transfer Record' in both the profile and ...
3
votes
1answer
275 views

Best Practices for Validate field in Salesforce

This is my scenario: - Object Name: Contact . - Field: -Status__c (Picklist) contains: Active ,Inactive or NULL -StatusDetail__c (Text) The requirement is whenever Status not null , we ...
5
votes
1answer
2k views

What is the Best Practice for the right Training Environment?

As we all know, good user trainings are crucial to ensure a high adoption rate and a successful CRM strategy. I'm hired quite regularly by customers to provide enduser trainings. Always there is the ...
10
votes
3answers
898 views

Checking 'Correct' Previous value method in Trigger design best practice

One of the most common questions on this forum is around trigger recursion. There are a few standard ways to prevent recursion. My method of choice when it comes to checking for field changes, is ...
1
vote
3answers
8k views

Write test class for webservice callout in apex class

I have one apex class in which I am calling one webservice of one of my managed package installed in my org. When I am writing the test class for my apex class, it is throwing the error callout ...
4
votes
3answers
2k views

Salesforce deployment best practices

I am very new to Salesforce .In salesforce , there is no clear strategy for release management and I am asking the wider Salesforce community to help me to see if the proposed release plan is OK. The ...
9
votes
3answers
6k views

What controls the 'severity' of ApexPages.addMessages(exception)?

I'm trying to crystallize out some 'best practises' for Visualforce Page exception handling. I think, at a minimum, a page should look something like this: <apex:page controller="PageController"&...
1
vote
2answers
694 views

Worrying about cross browser compatibility

Do we have to worry about rendering our salesforce custom page to different browser? If so, what are the things needed and to consider to solve or to have good practice developing a custom page ...
1
vote
1answer
2k views

BestPractice: Displaying Months on Visualforce Page

Is this a good practice in displaying months? Code Snippet: <b>{!CASE( IF( (MONTH(TODAY()) +3) > 12, (MONTH(TODAY()) +3) - 12, MONTH(TODAY()) +3), ...
-4
votes
1answer
890 views

Best Practices to call on-premise webservice from Salesforce

what is the best way to call the on-premise ws from salesforce? How can we make the connection and do the handshaking?
7
votes
4answers
729 views

BestPractice: Defining and populating Collections

What is the best practice when using collections. Example: This snippet: shortStudentMap = new Map<string,string>(); shortStudentMap.put('1', 'Student1'); shortStudentMap.put('2', 'Student2');...
1
vote
1answer
726 views

Best practices for designing a Custom Object. Experts please adivce

I am trying to design a custom object which i'm wondering if there could be any best practices regarding object design. i.e., Custom object design: Single record with multiple fields or Many ...
11
votes
2answers
417 views

Apex Modular Programming

I have a big Apex controller of a visual force page ,2500 lines of code, so i m wondering how can i separate implemented features in different module according to the topic. DealRowEdit(Apex ...
2
votes
1answer
1k views

How do I deactivate a picklist option in Professional Edition?

I have a picklist on Opportunities called "Demo Set By", which lets us recognize the Sales Development Executive who set up a demo (not the same as the owner of the opportunity, which is the Account ...
48
votes
3answers
11k views

General trigger bulkification - best practices

A general question asked from time to time on stack exchange is question of trigger bulkification. Therefore I have 2 questions: Which best practices are you using? What is the best way to handle ...
8
votes
2answers
440 views

First trigger: coding - best practices

This is my first production trigger and I'm just wondering if there is a more efficient way to write this code. Basically, if a campaign meets the criteria in the IF statement, I want it to create a ...
14
votes
3answers
9k views

How to avoid recursive trigger other than the classic 'class w/ static variable' pattern?

How can we avoid trigger get executed again and again (recursive trigger)? One way is to have a class with static variable and have boolean value and check it is true or false and changing the boolean ...
32
votes
1answer
2k views

Does an Apex or VisualForce code style guide exist?

Has anyone written an Apex or VisualForce code style guide, in the way of the Ruby Style Guide or jslint, or PEP-8, or any number of Java guides? I'm in the process on creating one for internal use ...
14
votes
1answer
780 views

Consolidate trigger methods or not?

I have a general best practices question about triggers. I have created a handful of triggers that perform different actions but are called by the same event, such as after account update/insert/...
15
votes
3answers
6k views

apex:include vs. Visualforce component, when and why?

I recently had a reason to look more closely at the standard apex:include component in Visualforce, and I'm intrigued by the intent behind this component. Would anyone be willing to share some ...
7
votes
1answer
2k views

SOQL: prevent SOQL injection - best practices

I have a query string that is as follows(no bulkification required)... String qryString = 'SELECT Id FROM Contact WHERE (IsDeleted = false and Name like \'%' + searchText+ '%\')'; searchText is a ...