Retrieving blob objects from Azure with Apex

3 octubre, 2016 Salesforce

Maybe you need to retrieve blobs stored in Azure Storage Services and save them as Salesforce attachments. Let’s suppose we have an attachment base64 encoded stored as a blob in Azure. We could retrieve it with the following snippet:

Sending e-mails from Salesforce using Amazon SES

3 octubre, 2016 Salesforce

SFDC has increased from 1000 to 5000 the number of e-mails that can be sent to external e-mail addresses within Winter ’17 release. This is really good news but still, in some cases, can be insufficient. I want to show you how you can send e-mails, in both HTML and text plain versions and with attachments using Amazon SES. However, as of now Amazon SES doesn’t support TLS v1.1, only supports v1.0. SFDC is going to disable all the communicationsRead More

Named credentials using OAuth

12 mayo, 2016 Salesforce

Sometimes you need to use the Rest API in your Apex Code to make callouts to other Salesforce Orgs or even to the same Org where you are executing your code. You could use Named Credentials to avoid storing user and password credentials (normally in an unsecure way) with OAuth. We will need the following components for achieving our goal: Connected App Auth Provider Named credentials Let’s see an example of set up; Code for testing:

Let’s call ourRead More

Setting RecordType for new records without query

27 febrero, 2016 Salesforce

My godness, how many queries would save if all of us knew this?

How come has this gone unnoticed? Anyway, better late than never!

CreatedDate in test classes

26 enero, 2016 Salesforce

Finally Salesforce fills the gap and allows you to specify the createddate field within test classes. You only have to use the Test.setCreatedDate method introduced with Spring ’16.

Better late than never!

Spring ’16

25 enero, 2016 Salesforce

Spring ’16 release is already among us. I was able to attend the 4 webcasts where the most important features were presented with nice demonstrations. I recommend you to join the Release Readiness Chatter group. There are very interesting documents, including the release notes for this release but also for past and future releases. Once you join to this chatter group, you will be able to download a pretty cool presentation: RR – Spring ’16 Release Overview. It contains aRead More

Manage UserTerritory table through REST API

22 enero, 2016 Salesforce

UserTerritory is one of the few objects that don’t allow DML Operations. However, we can manage it through the REST API. We could assign a User to a Territory by using the following APEX code:

If you want to remove a user from a territory, then the APEX code would looks like the following:

Happy coding!

Defensive future calls

14 enero, 2016 Salesforce

I would like to talk about the wonderful and simple pattern for making future calls. This pattern was presented by Dan Appleman at one of his sessions at Dreamforce this year. It looks like this:

Simple but very effective. To provide you a quick example. Let’s suppose we have a Session object and a trigger which is fired when a Session record is inserted and we need to make a future call when it happens. In our future methodRead More

Update relationships using External IDs

28 diciembre, 2015 Salesforce

Let’s suppose we have two objects, Speaker object and another one called company. The speaker record below has “Marc_Benioff” as External Id and it is related to a company called “SFDC”.   Its company looks as follows: We want to update the speaker’s company to another one called Microsoft   We can do it without using any SFDC ID, by using its External ID. You can achieve it by using the following code:

This is just an example, weRead More

Using JWT to share data between Orgs

27 diciembre, 2015 Salesforce

Let’s suppose we want to show some records in our Salesforce Org, let’s call this Org “A”, but this information is stored in another Salesforce Org, “B”. There are several ways to accomplish this requirement. We could use Salesforce-to-Salesforce to share records between different Orgs. We could also use third-party tools like Informatica Cloud or even creating our custom integration solution. The goal of this article is to describe how we can take advantage of JWT (JSON Web Token) forRead More