Entries in Salesforce tips and tricks (6)


Three Common Apex Coding Topics

If you're an admin of a big Salesforce org, then you probably had some users complain about unfriendly errors. If your Salesforce org is in any way customized then those errors are likely related to performance issues in the custom Apex code. Although custom Apex code can be powerful, it can sometimes hinder the overall performance of your Salesforce org. Today, I'm going to introduce three changes you can make in Apex Code that will improve the performance of your Salesforce:


Enhance Validation and Workflow Rules:

One example of the errors your users might get is one that includes FIELD_CUSTOM_VALIDATION_EXCEPTION. This error usually means that you have a scheduled batch that inserts/updates records without fulfilling a Validation Rule(s). Here are a few areas you can improve performance:

  • If you have a batch class, make the class calls a DML operation and that opt_allOrNone is set to False. This will allow the rest of the operation to still succeed even if the record fails.
  • Workflow Rules are most helpful in preventing duplicate records. If you have a lot of Workflow Rules in your org, you can cut down unnecessary processes by deactivating the Workflow and improving the Trigger to do the Workflow Rule'sjob.
  • Review Validation Rules with management and make sure they are necessary to fulfill business logic. Having too many validation rules and required fields can cause unit tests to fail, which will then prevent you from deploying a change set.

Increase Field Length:

If, for example, you have a Trigger that populates values larger than the field length, then you'll most likely get a STRING_TOO_LONG error message. One thing you can do here is to increase the Field Length; it is better to have a large value than getting an error message.


Rectify API Limits:

If your org has a lot of integrations with third party apps and that those integrations are used frequently, your users might then see a "REQUEST_LIMIT_EXCEEDED" error. There's no ideal solution to reducing API usage, but one thing you can do is to evaluate the current API usage in your org (SetupAdministration SetupCompany ProfileCompany Information) and figure out a way to reduce and disperse the number of API calls.


It is always a good idea to periodically review the current custom Apex Code you have in your org with management and stakeholders. Making these changes will not only cut down the number of errors your users encounter, but will help improve the performance and the overall user-experience in your Salesforce.

Jan032014 Tip: Freeze Users

When administering Salesforce, you can at times run into scenarios where a particular users’s account should no longer have access. An example of that is when you have reason to believe that a user’s account has been compromised or someone has just left the company and you want to prevent them from logging in. Normally you would just disable the user; however, if the user is part of a custom heirachary field - there are more steps invovled. A nice solution in the meantime us to just use the "Freeze" function. 

To freeze a user in your org, go to Your NameSetupManage UsersUsers. Find and click the user and then click “Freeze” to freeze the account. 

salesforce freeze user
After the user is frozen - the Freeze button changes to an Unfreeze button which performs (well, you get the idea).
Note: When you freeze a user, it does not free up a user license. In order to actually free up a licnense you have to perform an actual deactivation of the user.

Generate a Report Right From the Record Page

One of the major perks of using is its robust Reporting tool. Although the Reporting tool is quite capable, one drawback of it is that it's somehow separated from where you'd mostly spend time working through the data. If you're looking at a particular Lead record and wanted to create a report, you'd have to navigate to the Reports tab and create a report there. Today, I'll be showing you a quick way to create a report from the click of a button right from the record page. For my tutorial, I'll create a button an place it on the Leads page- I will then have the ability to generate a report on All Open Leads; right from that button.

Click to read more ...


Custom Objects in Salesforce

In Salesforce, you're able create a custom object to store a particular set of data where users can create and manage that data all under a tab . Today, I'm going to show you how to create a custom object in Salesforce and place its data under a tab.


Building the Structure of the Custom Object :

In this tutorial, I'll be creating a "Reservations" custom object to be able to create and track customer reservations.

  • To get started, go to SetupApp SetupCreateObjects. Then click "New Custom Object."

  • Next, fill in the name for the object and click "Save."

  • Under Optional Features, make sure to allow for Reports, Activities, and Tracking Field History.
  • Next, I'm going to allow for Adding Notes and Attachments. Tick the checkbox to "Launch new Custom Tab Wizard" to customize the look and feel of the tab.

Creating the Tab for the Custom Object:

Now that I've built the structure of the custom object "Reservations," I can create the Tab where the object will be stored.

  • Pick the appropriate style of the tab and click "Next'.

  • Next, add the profiles you want to see and/or use the "Reservations" objects, then click "Next".


  • Then, determine which Salesforce apps you want this object to be available and click "Save".

  • Finally, under Custom Fields and Relationships, create the appropriate custom fields for the object. I'm going to add a new custom field "Reservation Date and Time"
  • Now, you can see the "Reservations" tab at the top where you can create new reservations.


Salesforce Lead Queues

In Salesforce, Queues allow for management and organization of records in Leads, Cases, and custom objects. Lead Queues are particularly helpful because they allow you to funnel a group Leads into a queue based on a particular criteria whereby users in that queue can claim ownership of those Leads. For example, you can create a Lead Queue to distribute newly created Leads or those captured from web by region/territory (West Coast, North Pacific...etc) Today, I'll be giving an introduction on how to create a Leads Que.

Creating Regions/Territories:

First, we're going to create a queue for each region.

  • To get started, go to Setup> Administration Setup> Manage Users> Queues and click New.
  • Name the Queue and optionally, you can assign an email address specific for the queue; users in that queue will receive updates on actions.
  • Next, pick the object you want to create the queue in.



  • Next, assign users to the queue. Alternatively, you can assign a Group of users to a queue. Then click Save.

Assigning Rules for Lead Queues

Now that you've built the queue, it's time to create rules to automatically assign users to the appropriate region/territory queue. Go to Setup> Customize> Leads> Assigning Rules and click "New". In Assignment Rules, you can prioritize the order of rules.Assigning Rules will run on an ascending order.

  • First, set the order of the rule.

  • Enter the criteria on which you want the Assignment Rule to apply
  • If you have multiple rules and depending on the logic, you can modify the logic of the rules right under the list.

  • Finally, enter the name of the queue you want the records with the above criteria to go to. click Save.


And now, users assigned to the queue can have a list view of all records in that queue where they can assign ownership accordingly. Only those users and users of higher hierarchy will have access to that list view.


Salesforce Tip: Simple Ways to Find Record-Type ID

In Salesforce, "Record Types" are a way to arrange and classify data in an object. An example of how Record Types can be particularly helpful is when you want to assign different sets of data to different groups of sales teams.

Whenever you're working to customize or change something in Salesforce and need to reference Record Types, you must have the appropriate Record-Type ID. There are two ways to find them:

  • Go to the Record Type (Setup> Customize> (object)> Record Types). Click on the record type. Find the Record Type ID in the URL between id= and &type.

Alternatively, you can create a custom/formula field with the value Record-Type ID

  • Go to Your Name> (appropriate object) Customize> Fields> under custom fields, 
  • Click "New". 
  • Make sure you pick Formula as the type and then Formula Text and click Next. 
  • You can label the field "Record Type".
  • Finally, enter "RecordTypeid" under Advanced Formula tab.
  • Don't forget to hit "Save".