Unsubscribe Apex Email Service
Use an Apex class that implements the Messaging.InboundEmailHandler interface to handle an inbound email message for opting out the email address. [...]
Use an Apex class that implements the Messaging.InboundEmailHandler interface to handle an inbound email message for opting out the email address. [...]
The logic discussed in this post will show you how to get 18-character record Ids setup on any Salesforce object and have the value maintained by a lightweight Apex trigger. [...]
Illustrate some of the ways that variables work within batch apex classes. [...]
A queueable interface in Salesforce allows for the asynchronous execution of Apex jobs. It's similar to @Future annotated Apex classes except that a queueable interface can be monitored via the Salesforce user interface or by querying the AsyncApexJob table. [...]
This is the code coverage for a popular post where a PDF is created and attached to a record using a button click. [...]
Chaining together Batch Apex classes allows you to build robust Salesforce platform solutions. Sequencing Apex jobs ensures data accuracy and enforces flows. [...]
I often recommend making Salesforce development decisions based upon platform capabilities even if some of those capabilities have not yet been adopted by your business. With this in mind, I’d like to share the concept of being able to run some processes both synchronously and asynchronously. [...]
Many third party applications have their own APIs or webhooks that allow for easy and often simplified integrations between platforms. Another integration choice might be to use some type of middleware or enterprise service bus (ESB) to move data around. Either way [...]
Platform security is important. Creating a composite application for the AppExchange, developing integrations with open authentication (OAuth) or simply integrating salesforce with an internal system/platform can make your security team nervous. However, the Salesforce Crypto class should put your security folks at ease. [...]
We include time allocation when we invoice clients at the end of a given month. Time is tracked in a custom object within our Salesforce org so we simply run a report and export it to be sent to clients when billing. This is usually in the form of a spreadsheet and includes the date, hours, short description and employee. [...]
I like to group Apex methods by the object to which they apply. I find that this supports troubleshooting of code and ultimately reduces the amount of code in a given Salesforce organization. For example, every Salesforce developer that works in an Enterprise level organization or higher will find that more often than not they need to know the record types for a given object. [...]
Last year I wrote a post describing how to pass values to a new opportunity using the URL. This post is simply an alternative to accomplish the same goal of auto-populating values to a new record except using Visualforce and an Apex Class controller. For the purposes of our demonstration we will make some general assumptions about the values we want to pass to the new record. To keep it simple we plan on populating the Name, Stage and Close Date of the new opportunity. We will also make the logic flexible enough so that if Salesforce happens to pass additional information we will be able to include those key value pairs as well. [...]
I am working with a client that is deploying some existing Visualforce pages to international Users. The Visualforce includes some Date and DateTime values so I checked them to make sure they would render appropriately for people accessing the logic internationally. It turns out that the original Visualforce code uses the <apex:outputText> tag to drive formatting for much of the Date/DateTime values within the pages. Therefore, I am converting the occurrences of each <apex:outputText> tag to the Visualforce component I built for rendering. [...]
I was recently developing some Apex logic and encountered the UNABLE_TO_LOCK_ROW error while running my Apex unit tests for the new code. This UNABLE_TO_LOCK_ROW error message can happen when unit tests update the same record(s) at the same time or when unit tests try to create records with duplicate index field values. One way to avoid this UNABLE_TO_LOCK_ROW error is to simply turn off parallel test execution. This can be accomplished via Setup > Develop > Apex Test Execution. [...]
I just built a Visualforce application that people can use to associate a number of "child" records to a single "parent" record. Let's say that the application uses the Account object as the standard controller and then we extend the logic so that we can find, manipulate and link many Contact records. The functionality of the application is not important for this post but how we access the application is important. [...]
I am a big fan of developing Visualforce pages that are useful to humans. This means providing helpful feedback to the person interacting with the application in order to limit User frustration. In some circumstances this means providing clearer error messaging rather than simply outputting any system generated errors. [...]
A big part of building Visualforce pages is making sure that the human has a good experience while interacting with the page(s) you've designed. This means that you need to have a good way of handling errors when and if they occur. In this post I will highlight one of the simplest ways to handle an error by utilizing the apex:pageMessages tag within your Visualforce page. [...]
Years ago I wrote a post about how to use the User's locale settings in order to render a properly formatted DateTime value within a Visualforce page. Today I needed a locale based date value to render in Visualforce. I went out to that old post and reviewed it because I needed a place to begin coding. [...]
In my last post I provided a template for creating a Visualforce page rendered as a PDF. In this post I am going to show you how to generate that PDF file and attach it to a record within Salesforce by simply clicking a button/link. [...]
The Spring '15 Salesforce release introduced the concept of the @testSetup annotation. According to the documentation, methods defined with the @testSetup annotation are used for creating common test records that are available for all test methods in the class. [...]
Have you ever needed to deactivate a trigger for some maintenance activities on records or for a code deployment? At a high level, the act of activating/deactivating a trigger is simple. Go to your Salesforce sandbox, modify the status of the trigger and deploy the code. Depending on your unit test coverage for the trigger you may have to tweak the test class and include that in the deployment. [...]
A quick search for Salesforce wrapper results in the following definition. A wrapper or container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. That's fine but if you're new to the concept then it is likely that the definition of a Salesforce wrapper class is not as useful as a practical example of the logic. [...]
In this post I will be providing the Apex unit test code coverage for the trigger which was written in my last post titled Beginner Apex Trigger Example. As in that last post, this code is intended for Salesforce developers that are just starting out or administrators looking to learn more about Apex Classes. [...]
Businesses that utilize Salesforce Communities for partners instead of the standard partner portal may find that partners have the ability to search for and find the Contact record that corresponds to their Community User record. It would be nice if salesforce.com did not allow for this visibility because the Partner User is technically unable to make updates to the Partner Contact record. If they click the "Edit" button for the Contact they will receive the Insufficient Privileges message. [...]
My client has a use case where they want to convert a Lead but not create an Opportunity at time of conversion. The standard Lead conversion page is fine with the business owners but they want the "Do not create a new opportunity upon conversion" checkbox selected when the page is accessed by the Users in their org. This will allow Users to create an Opportunity in certain cases but default the option to false otherwise. [...]
Today I received an inquiry from a Salesforce administrator who read an article about using an Apex Trigger to reassign Contacts and Opportunities when Account reassignments happen outside of the standard Salesforce User Interface. She was encountering issues deploying the code. For some reason I failed to include any Apex Test class in that original post. [...]
I came across a use case earlier this month where a Salesforce business owner needed to be able to role out some functionality in a series of waves. Basically, the business was planning on running a pilot with a subset of users for a period of time and then at some interval they planned on granting access to additional users. The business owners wanted to be able to maintain that access and they wanted to be able to turn it on easily. [...]
Salesforce releases Communities, which is a much needed improvement to the stoned-aged partner portal user interface. I took part in the pre-release and found that the new functionality comes with some positives and some negatives. One big negative that I found was the inability for Community Users to delete records. Salesforce.com provided a long list of reasons why partners should not be deleting records and why this basic functionality is not provided. But let's be serious... I am not going to field calls from partners because they need me or another admin in the org to remove records that they no longer need. After a week of taking these requests during the pilot, I decided to make the functionality available to Community Users - just because it would save me and those same partners some frustration. [...]
I must admit that when I first heard about using a wrapper class in a Visualforce page I did not really grasp the concept. Reading the developer docs and reading other blogs didn’t really help either. It was only when I came across a practical use case that the concept really sunk in and I thought I would share that here for any other developers trying to make sense of the idea. [...]
I built this great Visualforce page where I display and allow for editing of many records at once. The initial business requirement was for only a few hundred records to be used in this application but, as usual, requirements morphed and now the business wants to be able to use this app for thousands of records. So guess what... we now encounter the "System.LimitException: Apex heap size too large" governor limit. WTF! [...]
I've been developing a lot of batch Apex routines lately. The nature of batch Apex is that it can run whenever resources are available and process many records while being more flexible with platform governor limits. So I might schedule a job to run and it could take anywhere from a few minutes to many hours. Many variables impact the run time of a batch routine. Things like the number of records being processed or platform resource availability. [...]
Here is an example regarding the use of the pattern and matcher methods in an Apex class. For this particular code sample I am using the methods to check a passed text string for the occurrence of leading zeros in the string and removing them when they exist. The code I have written here was actually used on a project where I had to validate that User records contained a valid EmployeeNumber value. And, as you probably know, this particular field is editable by users and is stored as text in the database. Rather than go through the trouble of creating another Number type field on the User object I thought it would be easier and less disruptive to simply check the value when I needed to reference it in any Apex logic. [...]
Today I participated in an online meeting, which discussed some of the "best practices" for testing Apex code, Visualforce pages, etc. One of the topics that was pretty much skipped but came up during the Q&A portion of the meeting was regarding how to ensure that the test code you write refrains from grabbing any actual live production data and only grabs the records created to facilitate the test. They discussed one way to do this but I have another and I thought it could be useful to other developers. [...]
Sometimes, I really dislike Visualforce... Last week I spent a ton of time troubleshooting a display issue for a page that was built by another developer. The issue was that the DateTime field for an object was not displaying properly. It was showing the value in GMT and not the timezone of the user. After spending way too much time reviewing everything I decided to build a custom Visualforce component to eliminate the problem altogether. [...]
More than a while ago, I wrote about populating query results to a picklist for use in a Visualforce page. That post receives a lot of traffic and I get some additional emails regarding that topic. So I thought I would put together another post similar to that one but with a bit of a twist. In the sample I will cover in this post I am going to show you how to use the methods for the Describe Result sObject in order to create picklists within Visualforce pages. [...]
I recently encountered an 'Invalid Query Locator' error while developing a batch Apex class that took me too long to resolve. I was able to trial & error my way through it until I got the code to work but I found it very frustrating that I was unable to find a solution on another developer board or blog. So here's my attempt at helping others that may encounter this problem. [...]
Let's say that you're building a Visualforce page and you want to provide a picklist option for your users on the page. If the field where you want to store the selection is a picklist then you have no issue because the field definition will define that the page display a picklist when the Visualforce page is rendered. However, let's say that you want to display a picklist option based on a query from another object. How would you do that? [...]
Reduce Repetitive Tasks, Eliminate Errors & Free Up Your Administrators.
It might lead to a sale. Or it might make you feel good.