development

Mocking JSforce with Jest

by Patrick Connelly posted on March 30, 2021

Testing is one of the most important things you can do your code. However, when using a library that requires access to a remote system unit testing can become problematic. You don’t want to have to have a real connection and pull down real data since this is slow and requires anyone contributing to your project to set up the remote system as well. This is where mocking comes in with Jest.

Mocking allows you to detach a module from making a remote call and allows you to define the data that it returns. This means that you can modify the data how you need to provide a small data set or a large data set or even error out on demand.

In this post, we’re going to look at how to set up mocking for JSforce to test logging in and mocking out making queries.


JWT Bearer Authentication: Salesforce and Node

by Patrick Connelly posted on March 08, 2019

If you’ve done much API generation then you’ll that you don’t want to have to make your users authenticate multiple times just because your API is going somewhere external. For example, if you have an API that reaches into Salesforce but your app uses Google SSO, you don’t want to have to present an oauth screen to your user after they’ve already authenticated. To work around this, you can use a JWT Bearer flow to login on behalf of a user and get a access token to work with.


Single Sign-On in Salesforce with Google

by Patrick Connelly posted on March 05, 2019

I started down this path to flesh out a proof of concept for a related task. However, the Single Sign-On provider that we use is difficult to get access to and not worth the time to try to get permission to use it. So instead, I thought I’d just use my personal Google domain as the identity provider so I can get it done faster. So I’ve decided to document my journey and hopefully help someone else set this up.


Change Data Capture with Nodejs

by Patrick Connelly posted on January 23, 2019

There’s a new feature in Salesforce called Change Data Capture that allows you to subscribe to a Cometd endpoint and stream changes to most or some of your objects. I’ve talked in a previous post about how to get data out of Salesforce and this seems like it might be the front-runner for one of the best ways. I would still plan on ways to get data if it exceeds the three day replay period and you’ll also need a way to do your initial data import.

What data can I get with Change Data Capture?

In a perfect world, everything you’d need would always live in Salesforce and you’d never have to worry about backing up data. Well, we don’t live in a perfect world. Lot’s of times you need to get data out of Salesforce and get it into an external system. You could do this for data backup, for populating a search index, for sending messages to an external system. With Change Data Capture, you can do this type of data flow in real-time.

Change Data Capture supports the following standard object (at time of writing):

  • Account
  • AccountContactRole
  • Asset
  • Campaign
  • Case
  • Contact
  • Event
  • EventRelation
  • Lead
  • ListEmail
  • Opportunity
  • OpportunityContactRole
  • Order
  • OrderItem
  • Product2
  • Task
  • User

In addition to the standard items above, Change Data Capture supports all custom objects.


PMD and Salesforce: Clean Code is Awesome

by Patrick Connelly posted on July 06, 2018

If you’re not aware, having clean code is more than just about readability. It’s about sustainability, re-usability and knowing that your code is doing what you want it to do. This is where PMD comes into the picture. PMD is a static code analysis tool that takes code from many different languages, analyzes it and provides you with feedback. Fortunately for the Salesforce world PMD now supports Apex as one of it’s languages. So, let’s dive into how to set it up, run it and then how to use some of the rules included.


Postman – Logging in to Salesforce

by Patrick Connelly posted on August 08, 2017

We’ve been slowly replacing all of our SOAP endpoints with REST endpoints inside of Salesforce. The upside of this is that they are much easier to use. The downside is that they are harder to functionally test without a bunch of work to generate session Ids. (This was made even more frustrating by a recent change that obfuscates out the session id in debug logs) So, I decided to figure out how to run a Postman request that would then store the session id and server url for later requests to use. This post will cover how to set that up and use this one request. I plan on writing more in-depth blog later about how to use Postman to test custom REST endpoints later.


JMeter – Logging Into Salesforce for Automated Testing

by Patrick Connelly posted on June 29, 2017

I’ve written quite a few web services in Salesforce, and I’ve written about them a couple of times. And my love of testing is pretty well known. One thing that’s always been a problem is testing the web services in an automated fashion as a real consumer would. I’ve talked about manually testing them with SoapUI before, and while useful doesn’t fit into an automated process well. So let’s jump into the world of JMeter and how we can automate our web service testing for Salesforce.


Jira Attachments: Getting an attachment from a Jira

by Patrick Connelly posted on June 02, 2017

I previously did a post on writing Jira Attachments from Salesforce, and the question has come up of how to write Jira Attachments into Salesforce. This is actually WAAAAY easier than it was to write attachments out. The way that the data is structured from the Jira, we can get a list of all the attachments and the link to it’s content directly from the Jira GET request. This makes for way fewer calls to get the actual content of the attachment.


Milestone Trigger Time Calculator

by Patrick Connelly posted on April 26, 2017

I recently stumbled upon a “new” feature in Salesforce that allows you to use an Apex class to calculate your milestone trigger time for entitlement processes. Given a new feature that I’m working on for our entitlement process, I thought to myself that this could be a good chance to play with it and see what I could do. If you’re not familiar with the entitlement process in Salesforce, take a chance to look over (or run through) my hands-on training for entitlements so that you’re familiar with the terminology and the concepts since I’ll be jumping right in.


Javascript and Visualforce: Tips and Tricks

by Patrick Connelly posted on January 09, 2017

In the web 7.0 or whatever version of the web we’re in, Javascript is king. Now, there’s lots of stuff you can do directly with Visualforce (like dynamic picklists) but sometimes for the best user experience you’ll want to use Javascript to make it even better. There are lots of Javascript tutorials out there and there are lots of Visualforce tutorials out there (don’t forget Trailhead) so I’m going to talk about some tricks that people should know when working with Javascript on Visualforce


Managing reports and dashboards programatically

by Patrick Connelly posted on December 08, 2016

One of the challenges you get when you have a special snowflake org is lots of people want to write lots of reports and lots of dashboards for each of their special use cases. Now, lots of times reports aren’t the right way to go with this so you have to educate your users on the right way to do this and their old reports get abandoned. Or a user will create a one off report and never look at it again. As it stands right now, we have several thousand reports that haven’t been looked at in more than 90 days.


List of objects for POST in Apex REST

by Patrick Connelly posted on November 29, 2016

A while ago, someone posted on the developer boards a question about how to bulk create tasks for contacts via REST. I thought it was an interesting enough problem to cover how to do it and how to format the data correctly to use it.

Prerequisite

Before we can bulk create tasks for a contact, we need to know how to identify those contacts. To do this, I create an unique external Id field called External_Id__c. As long as your contacts are uniquely identifiable then it doesn’t matter what field you use. For this example I have two contacts under different accounts “Andy Young” with an external Id of “ayoung” and “Edna Frank” with an external Id of “efrank”


Standard picklist changes Winter '17

by Patrick Connelly posted on November 24, 2016

I wrote a couple of weeks ago I wrote about the GlobalPicklist changes in Winter ‘17. This past week I learned that there was another change in the release notes that I overlooked.

After updating the Case object to API 38.0 I didn’t notice that the Case.Type field had changed. In API 37.0 this is what the Case Type field looks like

<fields>
    <fullName>Type</fullName>
    <inlineHelpText>The case type</inlineHelpText>
    <picklist>
        <picklistValues>
            <fullName>Value 1</fullName>
            <default>false</default>
        </picklistValues>
        <picklistValues>
            <fullName>Value 2</fullName>
            <default>false</default>
        </picklistValues>
        <sorted>false</sorted>
    </picklist>
    <trackFeedHistory>false</trackFeedHistory>
    <trackHistory>false</trackHistory>
    <trackTrending>false</trackTrending>
    <type>Picklist</type>
</fields>

And this is what it looks like in API 38.0

<fields>
    <fullName>Type</fullName>
    <inlineHelpText>The case type</inlineHelpText>
    <trackFeedHistory>false</trackFeedHistory>
    <trackHistory>false</trackHistory>
    <trackTrending>false</trackTrending>
    <type>Picklist</type>
</fields>

In the turmoil of all the other changes to the object file, I completely missed the change. And when the deployment failed I was at a loss to figure out why. The failure wasn’t about the picklist in particular, it was about the picklist value in a record type.


Table Header in PDFs with Visualforce

by Patrick Connelly posted on November 15, 2016

One of the problems I had with the way that we generated the PDFs in previous Battle Station Invoice posts was that the table header wasn’t repeated for long lists of supplies or resources that continued on the next page. There’s a simple way to add the table header for PDFs generated in Salesforce using the flying saucer mark-up but that won’t generate the table header correctly for us. It seems that the -fs-table-paginate tag does not play well when combined with a Visualforce component so we’ll need to take a bit more of a native CSS approach.

If you are doing this with plain Visualforce and apex:pageBlockTable, the -fs-table-paginate is the way to go.

GlobalPicklist changes in Winter '17

by Patrick Connelly posted on November 11, 2016

Like many companies, we have a deployment process in place to handle changes in seasonal releases in Salesforce so that when a sandbox is ahead of production, we can still deploy to both without having to wait for production to be updated. Then, after both the release hits production, we go through a manual process of updating the API (primarily the ant-salesforce.jar) and the metadata to the most recent API version. Typically this just involves updating the jar and updating the API version in the request, pulling down the updated metadata and writing it to SCM. However, with the Winter ‘17 release we saw a problem trying to deploy our GlobalPicklist files after updating the API.


Japanese Users and Reports

by Patrick Connelly posted on November 04, 2016

There are lots of times where working with Salesforce would be so much easier if it weren’t for the users. But, they’re the reason I still have a job, so you’ve got to put up with them. One of the problems with users is they tend to like to live all over the world and they all have their own ways of working and cultural eccentricities. One of the ones that has caused us grief in the past (both in Apex and in reports) is the fact that Japanese users in Salesforce default to “Lastname Firstname” when using the Name field on Users. Now, this in and of itself is not really a problem because lots of reports are written for a single user or for a relatively small group of users (such as others in the same geographical location). Where this becomes a problem is when locales get mixed with reports and all hell breaks loose.


Child Package: Extending a Manage Package

by Patrick Connelly posted on October 18, 2016

In an effort to try to reduce the amount of code in our base repository we’ve been looking at writing managed packages that we install in our production org and then delegate the development and maintenance of these packages off to other teams. Being a Open Source company we also want to try to offer what work we’ve done to other people. However, not everything we want this package to do is useful outside of our business. To solve this, we’re releasing the base package and then creating a private child package to hold most of our business logic and custom fields.


Dreamforce recap

by Patrick Connelly posted on October 13, 2016

So it’s been a week since the end of Dreamforce 2016 and I’ve had some time to soak in what was talked about. This year my task for Dreamforce was to go and get some pretty specific answers. So, instead of talking about everything that happened at Dreamforce and what I think about it, I’m going to talk about the three things I was tasked with looking into.


Live Agent Quickstart

by Patrick Connelly posted on October 03, 2016

With the recent updates to the licensing model at Salesforce, lots of companies now get Live Agent licenses included. Because of this I’m working on a hands-on training for how to setup Live Agent and use it in Service Console. As you could guess, this isn’t an quick thing to do so I’m splitting it up into parts.

Quickstart

Why?

One of the hardest parts of Live Agent to test out for non-developers is the actual web front end part. If write the HTML locally and then you can test it but others can’t. To make it so others can test it, you either have to set up a web server or figure out how to deploy it to a cloud provider such as Heroku or Openshift. And that can be pretty daunting for someone that’s just trying to setup a proof of concept or is just working on the configuration side and will pass it off to someone else from their web team.


Namespaced Component in Managed Packages

by Patrick Connelly posted on September 13, 2016

As part of my managed package crusade I decided I should delve into the world of Visualforce from a managed package. While pure Visualforce is going to be in my package that’s not nearly as interesting as packaging and using namespaced components as part of the package. So let’s take a look at how we can use a namespaced component.

Namespaced Component

The component that I created in my packaging org is simple. The Visualforce page provides an account Id and the component lists out each of the account’s cases. This component isn’t going to win any awards for originality, but it will serve it’s purpose.


Namespaced REST in Managed Packages

by Patrick Connelly posted on September 07, 2016

Recently I’ve been working more with managed packages and I knew that I’d be writing REST interfaces inside that package. However I had no clue how namespaced REST interfaces would be presented or how you accessed them. I was afraid that there could be conflicts. For example if the package exposed /lastcase and the customer’s org had /lastcase how would they play together. I’m very happy to announce that the folks at Salesfore are on the ball and the platform handles it wonderfully.


Quick Deploy with Solenopsis

by Patrick Connelly posted on August 22, 2016

In Spring ‘15 Salesforce released a feature called “Quick Deploy” that allows you to only run a small subset of tests when you do your deployment instead of running all the tests. When you’re in an org like ours that running all tests can take upwards of 5hrs (or longer if the moon is aligned incorrectly) this is wonderful. Let’s take a look at how quick deploy works and how you can use quick deploy with Solenopsis.

How Quick Deploy Works

Quick deploy simply runs a provided list of tests when you run your deployment. This deployment is then staged under your Deployment Status in setup. Once the all the tests have run you’ll get a button that let’s you quick deploy.


Visibility for Apex in Managed Packages

by Patrick Connelly posted on August 16, 2016

Now that I’m starting to spend time playing with packaging code for use I decided to dig into how access modifiers affect visibility of methods and classes inside of managed packages.

Visibility Access Modifiers

Before we get started, let’s review what options we have for defining visibility in Apex

private – Methods, classes and variables marked as private are only visible inside the same class. If you define something as private then it cannot be accessed from an external class

public – Things that are marked as public are available for use by anything in the same namespace.

global – Things marked as global are available for use by anything on the platform.

Typically, public and private are enough for most implementations since your code resides inside the same namespace. When writing code to be used by others from your managed package you’ll want to make it global.


Heatmap for Contact Locations

by Patrick Connelly posted on August 01, 2016

One of the cool new features in Summer ‘16 is the ability to take a built in (or custom) address and automatically get that addresses latitude and longitude with SOQL (Read More). So took this as an opportunity to learn some more about it as well as some other mapping technologies. So for this my goal was to be able to create a heatmap of all the contact’s location under an account and place this on the account page.


Opensource Update

by Patrick Connelly posted on July 28, 2016

This week is going to be just a social update on a couple of projects that I’m working on. I’ve got plans for a big neat post next week.

Me Code Pretty One Day…

I was hoping to present this at Dreamforce this year but it doesn’t look like that’s going to happen. So instead I’ll just talk briefly about it here

Apex StyleguideLink – I’ve been asked several times what our team does for it’s code style and I’ve been working on an online style guide. It’s really a work in progress and will probably pivot a bit once Apex Checkstyle is complete. Right now all the rules are enforced by regexes and it doesn’t scale well and has a lot of false positives. If you want to create your own styleguide, feel free to fork the project. I’ll add build instructions for the site soon to make this easier.

Apex CheckstyleLink – This has been something that’s been in the works for a while. Initially I tried to just make an extension to Checkstyle but there was just too many problems with that. So instead I completely forked Checkstyle and modified the grammar to help support Apex. While the project builds and it works on some very simple Apex code, it’s nowhere near ready for the big time. I’m going to keep working on it and hopefully someday soon it’ll be ready.

Other Projects

EscalationsLink – Another project still very much in it’s infancy. The idea behind this is to make an easy way for support centers to track escalations to cases. The plan is to have this both as a managed package as well as having the source available if you want to install it as unmanaged code.

SalesforceAppsLink – This is just a repo for random code that I’ve worked on that others may find useful. Right now I think the most useful bits are under the node_scripts directory.

Hands On TrainingLink – Training is in my blood and it’s something I’ve always loved doing. You should checkout my hands on training. I have plans to migrate some others over to it as well as writing a couple more. You can follow the project if you want to be notified of updates.


Solenopsis with XSLT

by Patrick Connelly posted on July 22, 2016

There’s a great feature we use all the time in Solenopsis that isn’t as documented as it should be. This is the ability to write an XSLT to apply to your objects at time of pull, push or both.


XML Parsing in Apex

by Patrick Connelly posted on July 14, 2016

Doing XML parsing in any language can be pretty tough. I wanted to share a quick how to for doing XML parsing in Apex based on a previous board post.

Let’s start with the data we’re trying parse

<?xml version="1.0"?>
<_CREDIT_SCORE for="Bob Dole">
  <_CREDIT_SCORE _CreditScore="668" _ReportingAgency="Experian" />
  <_CREDIT_SCORE _CreditScore="658" _ReportingAgency="TransUnion" />
  <_CREDIT_SCORE _CreditScore="660" _ReportingAgency="Equifax" />
</_CREDIT_SCORE>

For this data we want to pull out who the credit report is for and the credit data from the for field as well as from each of the _CREDIT_SCORE elements the agency and the score.


OAuth Flow for service users in Salesforce

by Patrick Connelly posted on July 05, 2016

When this article was originally written Named Credentials weren't really a thing (or at least not something I really knew about). Using that is going to be a better and more secure way to do this.

A very common use case for integrations with external systems is to have a service user that is authenticated and all subsequent interactions happen via that user. This flow is super easy when you can do username / password auth, but it becomes much harder when you’re only option is to use the oAuth flow.

Use Case

In a recent developer board post, a community user asked for help storing their credentials from the oAuth flow to box.com and then create a new folder whenever an account was created. The problem they were facing is that when you do the initial oAuth flow, you have to approve the use of the app and this requires human interaction. This is not something you can do inside of a trigger, so we’ll need to find another way to do it.


SoapUI TLS 1.2

by Patrick Connelly posted on June 27, 2016

Soon, Salesforce will be requiring all connections to be TLS v1.1 or higher. This poses a problem for anyone using SoapUI with Java version 1.7 as that version of Java does not have TLS 1.1 or higher enabled by default. If you attempt to connect to an instance that has the “Require TLS 1.1 or higher for HTTPS connections” enabled you will get an error like the following

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
        <soapenv:Fault>
            <faultcode>sf:UNSUPPORTED_CLIENT</faultcode>
            <faultstring>UNSUPPORTED_CLIENT: TLS 1.0 has been disabled in this organization. Please use TLS 1.1 or higher when connecting to Salesforce using https.</faultstring>
            <detail>
                <sf:UnexpectedErrorFault xsi:type="sf:UnexpectedErrorFault">
                    <sf:exceptionCode>UNSUPPORTED_CLIENT</sf:exceptionCode>
                    <sf:exceptionMessage>TLS 1.0 has been disabled in this organization. Please use TLS 1.1 or higher when connecting to Salesforce using https.</sf:exceptionMessage>
                </sf:UnexpectedErrorFault>
            </detail>
        </soapenv:Fault>
    </soapenv:Body>
</soapenv:Envelope>

Parse JSON with Reserved Words

by Patrick Connelly posted on June 21, 2016

One of the great things about Salesforce when dealing with external webservices is being able to easily parse JSON into Apex classes. I’ve covered this in several previous posts. However a common problem is that the system you are integrating with is they may be using a variable name that is reserved. With the following data, we can see that there is a variable named “case” if we ant to parse this data into a Apex class we won’t be able to because case is a reserved name.

{
    "data": [
        {
            "case": "123456",
            "subject": "Test case"
        }, {
            "case": "789012",
            "subject": "Another case"
        }
    ]
}

Clean REST Endpoints in Salesforce

by Patrick Connelly posted on June 13, 2016

One of the things I love working on are webservices. However, one of the things I dislike about using SOAP is that using the endpoint isn’t as nice as it could be. This is something that has been addressed by how REST endpoints are interacted with. By writing clean REST endpoints, your users can easily understand what is going on under the hood

Clean REST Endpoints

What do I mean by clean REST endpoints? Let’s take a look at two possible URIs and see which ones are cleaner and easier to understand. For the examples below, we are going to have two URIs, one to get a case by case number, and one to get it’s comments

#Get case using url parameter
curl "$SFDC_URL/services/apexrest/v1/cases?number=012345"

#Get case comments using url parameter
curl "$SFDC_URL/services/apexrest/v1/comments?number=012345"

#Get case using number in url
curl "$SFDC_URL/services/apexrest/v1/cases/012345"

#Get case comments using number in url
curl "$SFDC_URL/services/apexrest/v1/cases/012345/comments"

While the parameters are perfectly acceptable, they are not pretty. Also, it is difficult as a programmer to know if the param you have add to the URI is number, or casenumber or what. So instead if we have clean REST endpoints, we have the case number as part of the URI and it is just more logical as to knowing how to get a specific case.


Trailhead: Apex Specialist Superbadge

by Patrick Connelly posted on June 06, 2016

Salesforce has released a new section under Trailhead called Superbadges, and they’re pretty awesome.

Superbadges?

Superbadges.

So if you’re familiar with Trailhead Projects, Superbadges are very similar to these but instead of guiding you through the process, you are given a set of requirements and you are required to implement it. All of the badges have requirements that you must meet before you can even start them. This is nice because it encourages you to learn the content before diving in. This way, the challenge of the badge is just building on your existing skills instead of teaching you new ones. For the first release, there are four Superbadges that you can earn:


Entitlements Hands-on Training

by Patrick Connelly posted on June 02, 2016

At Dreamforce 2015, I wrote a hands-on training for Salesforce University and presented it both as a Dreamforce session, as well as recorded it for use on their site. I had a great time writing the content as well as delivering it in their studio. However, the problem is that the content is locked in place and the content isn’t 100% correct. Since publishing it, I’ve found some typos in the guide as well as some mistakes in time calculations. Because of this, I wanted to make the training available in a format that was easier to update as well as easier for people to report issues against.


Trailhead: Entitlement Management

by Patrick Connelly posted on May 23, 2016

It’s a pretty well known fact that I’m a big fan of Entitlement Management. I’ve given a Dreamforce talk, been recorded by SalesforceU, and even have a github repo for it (it’s a work in progress). So when I heard that the Trailhead team was releasing a new Entitlement Management module I was ecstatic.


Watermarking PDFs in Visualforce

by Patrick Connelly posted on May 09, 2016

Keeping on the PDF and Trailhead theme, lets take a look at adding watermarks to our PDFs. There was recently a developer boards post about watermarking a PDF and it dovetailed nicely into the previous posts.


Git push to multiple remotes

by Patrick Connelly posted on May 02, 2016

With today’s PaSS offerings, you may find yourself in a position like I was. Let’s take the scenario of hosting an application on Openshift, but also wanting to store that code on Github. Historically, anytime you wanted to do a git push to both Openshift and Github, you’d have to submit two push commands. Now, you could write your own git alias to do that for you, but I recently discovered a better way to do this. (This also works if you are using Heroku)


Field Sets and Dynamic Visualforce

by Patrick Connelly posted on April 25, 2016

One of the downsides of the code I posted a couple of weeks ago to generate PDFs is that if you want to add new fields to your invoices, you have to edit the Visualforce page. By updating our Visualforce and using field sets, we can dynamically add fields to our invoices


PDF Attachment with Visualforce

by Patrick Connelly posted on April 18, 2016

After last weeks post, let’s take a look at how we can send a PDF attachment via a Visualforce email template. Our goal is to be able to automatically send an invoice to our customer whenever their Battle Station is fully operational. We will be taking the Battle Station Invoice PDF and making it something we can attach to an email and then create a workflow to send that email when the status changes to complete.


PDF Headers and Footers with Visualforce

by Patrick Connelly posted on April 04, 2016

Over the past couple of months, I’ve seen several posts on the Developer forums asking how to set PDF headers and footers with Visualforce. I decided to sit down and try my hand at it. If you have done the Battle Station app on Trailhead, you can try this out on your own sandbox! We will be generating a PDF invoice for the Battle Station app that includes a first page header image and a dynamically generated footer.


Rosetta Code: A call for help

by Patrick Connelly posted on March 27, 2016

If you’ve ever started to learn your second programming language, you know how important it is to have example of the new language to help you understand the syntax. In my opinion, once you’ve learned the concepts behind programming (loops, control statements, etc) it’s pretty much just learning the syntax to get started. That’s where the folks over at Rosetta Code come in, to make it easier to learn new languages.


Testing NOW in Apex

by Patrick Connelly posted on March 21, 2016

If you’ve ever written a trigger that stores Date.now(), then this scene from Spaceballs may seem very familiar. This is how I feel when testing now.

Testing now

  • Dark Helmet: What the hell am I looking at? When does this happen in the movie?
  • Colonel Sandurz: Now. You’re looking at now, sir. Everything that happens now, is happening now.
  • Dark Helmet: What happened to then?
  • Colonel Sandurz: We passed then.
  • Dark Helmet: When?
  • Colonel Sandurz: Just now. We’re at now now.
  • Dark Helmet: Go back to then.
  • Colonel Sandurz: When?
  • Dark Helmet: Now.
  • Colonel Sandurz: Now
  • Dark Helmet: Now.

The problem comes down to knowing when now is. Obviously, now is something that’s in constant flux and will change throughout your test. But there are ways to be able to know when now really is in your test.


Extending objects for JSON parsing

by Patrick Connelly posted on March 16, 2016

In a previous post, I talked about how to pull Runkeeper data into Salesforce. The key portion of this revolved around JSON parsing of the data into Apex classes. In this post I’ll talk about how to use Object Oriented structures to extend the classes previously written to support additional data.


Runkeeper data in Salesforce

by Patrick Connelly posted on March 01, 2016

Runkeeper and Salesforce

For the past couple of years I’ve dabbled in running and getting data from Runkeeper. I decided that I’d give it a try to have the entire process inside of Salesforce. This provided an interesting challenge for me, since it’s the first time I’ve setup the oAuth flow from Salesforce back to Salesforce. This post will likely be the first of a couple in this theme of pulling data from Runkeeper. The code included here is just a base for what can be done. I’ll be maintaining an updated version of the RunkeeperUtils class on my github, so make sure you check there for the most recent version of everything. So let’s go over how we can do this


Trailhead: Navigate the Salesforce Advantage

by Patrick Connelly posted on February 22, 2016

Trailhead: Navigate the Salesforce Advantage

The Trailhead team released another set of fantastic modules this past week. But unlike many of the other modules, these delve into the world of Salesforce itself, and not really into Salesforce the product. Let’s take a look into each of these modules a bit deeper.


Amazon S3: Attaching a File in Salesforce

by Patrick Connelly posted on February 16, 2016

Last week I covered how to send an attachment from Salesforce to Jira. This week we’ll cover how to attach a file from Salesforce into the Amazons S3 cloud. Unlike the Jira uploading, we will not be associating these files with a specific case, but instead will be uploading them to a generic bucket. This can be modified by changing how the filename is generated on line 8 of the code.


Jira: Attaching a File in Salesforce

by Patrick Connelly posted on February 09, 2016

I was recently challenged with the task of sending an attachment from Salesforce to Jira. Looking over the documentation, this doesn’t appear to be too hard. The toughest part is that Jira wants a multi-part form upload for the attachments and this can be a bit of a headache to do in Apex. Following this post as a guide for multi-part form upload, we can adapt it to the format that Jira expects.


SSL and Outbound Messaging

by Patrick Connelly posted on February 01, 2016

Recently I started setting up some Outbound Messaging to I needed to set up a blackhole (messaging sink) for messages to go to until we had stood up the real messaging endpoint. To host this I setup a simple nodejs service on our company’s externally available (but internally hosted) instance of Openshift. This service simply sends back the appropriate ACK for any XML that is POSTed to it.


apex:gaugeSeries and display report data

by Patrick Connelly posted on January 25, 2016

I recently helped out on a Developer Boards post about recreating a dashboard in Visualforce to create a home page component. This works great with analytics:reportChart assuming you are not using a gauge chart. However if you want to use a gauge chart then you’ll have to dive into the apex:gaugeSeries component and personally I found the documentation a bit lacking. So, let’s dive into how to create a gauge chart based on a summary report.


Salesforce and Fuse: Rolling your own ESB

by Patrick Connelly posted on January 19, 2016

There are lots of reasons why you would want to send data from Salesforce to a third party system. A simple example that comes to mind is to index your Salesforce data for external searching. Now, there are lots of 3rd party companies that you can do integration with, but most of these are externally hosted and do not give you the granular control that you may want or they may not give you access to your backend systems in a way you want.


Strip extensions from company names

by Patrick Connelly posted on January 10, 2016

In a recent developer boards post, there was a person asking how to programmatically strip extensions from the end of company names. This seems like an interesting problem that can be solved with regular expressions with the data stored in a custom setting

Custom Setting

Custom Setting Definition


Salesforce1 Actions with Visualforce

by Patrick Connelly posted on January 03, 2016

Salesforce1 Actions can be very powerful. Most of the examples I have seen regarding Salesforce1 Actions have been around Global Actions that show up on the home page. I recently had the chance to play around with object specific actions and found that combined with Visualforce pages they can be very powerful.

Goal

The goal of this post is to create two quick actions for the Lead object. One that will reject a lead and one that will accept a lead.

Salesforce1 Goal

We will be doing this via a Visualforce page that has an onload action. This will be useful so that we can re-use this both for a standard page layout button as well as for our Salesforce1 Action


Trailhead: Man your battle stations!

by Patrick Connelly posted on December 18, 2015

It’s no secret that I’m a huge Trailhead fan. I’ve written several posts about it. As much as I love Trailhead, I do find that the standard modules are a little tough for new people to see how it can be useful. That is where the Projects come in. The Trailhead Projects give you a goal and walk you through how to do something from start to finish, and in my opinion, it really helps to solidify how the platform can be used and what powerful things you can do without code.


JSON Deserialization in Salesforce

by Patrick Connelly posted on November 30, 2015

I have been several posts recently on the Developer Boards around JSON deserialization and some weird and convoluted ways to convert it into something that is useful for Salesforce. Let’s talk about what I have found is the cleanest way to handle JSON deserialization.

JSON Payload

Let’s take a look at our JSON payload. I am taking the payload from the docsample Heroku app since it’s an easy way to get consistent data from a webservice.

{
  "invoiceList": [
    {
      "totalPrice": 5.5,
      "statementDate": "2011-10-04T16:58:54.858Z",
      "lineItems": [
        {
          "UnitPrice": 1,
          "Quantity": 5,
          "ProductName": "Pencil"
        },
        {
          "UnitPrice": 0.5,
          "Quantity": 1,
          "ProductName": "Eraser"
        }
      ],
      "invoiceNumber": 1
    },
    {
      "totalPrice": 11.5,
      "statementDate": "2011-10-04T16:58:54.858Z",
      "lineItems": [
        {
          "UnitPrice": 6,
          "Quantity": 1,
          "ProductName": "Notebook"
        },
        {
          "UnitPrice": 2.5,
          "Quantity": 1,
          "ProductName": "Ruler"
        },
        {
          "UnitPrice": 1.5,
          "Quantity": 2,
          "ProductName": "Pen"
        }
      ],
      "invoiceNumber": 2
    }
  ]
}

So we can see here that the data provided is an invoice list and each invoice contains data and line items for that invoice.


Email Reference Id: Winter 16 Changes

by Patrick Connelly posted on October 12, 2015

In the latest Salesforce release (Winter ‘16) there was an update that changes how the Email Reference Id (aka Thread_Id) is generated.

Old Email Reference Id

The old email reference Id was in the format of [ ref:orgId.caseId:ref ] and was really easy to generate. All you had to do was concatenate the currentUser’s orgId and their caseId together

public static String refId (String orgId, String caseId) {
    return '[ ref:' + orgId + '.' + caseId + ':ref ]';
}

Run this and you’re done. Easy peasy.

New Email Reference Id

This all changed with the release of Winter ‘16. Once this hit the way the email reference Id changed so much that the Email to Case process wouldn’t even parse the old thread ids. So when a reply back to an email containing the old email reference id would come in, it would create a new case instead of pairing the EmailMessage with the Case Id in the thread_id.


Comparable: Sorting Objects in Salesforce

by Patrick Connelly posted on October 10, 2015

Like most Object Oriented languages, Apex will allow you to make an order List of objects that you can then iterate over and manipulate. However, Apex will not let you use the built in sort method for List to sort sObjects by a field inside. To do this, we have to implement our own comparable class to do the sorting for us.

Basic sorting

Implementing Comparable

Let’s take a look at a simple class that takes in an Employee object, stores the employee’s data in it and allows us to sort a list of Employees by their salary.


Coveralls: Code Coverage for Salesforce

by Patrick Connelly posted on August 23, 2015

When we started working on the Apex Lodash project we knew we wanted to publicly post our code coverage percentage. To do this we chose to use coveralls.io since it is free for open source projects.

Travis CI

Travis CI logo

In a previous post I talked about how to setup Travis CI to deploy your Salesforce code automatically. We will be updating the Travis CI configuration to push the testing results to coveralls.

Coveralls

Coveralls logo

There don’t seem to be too many options around for code coverage display on the Internet. Coveralls has lots of options for various coding languages and a pretty nice interface. Like Travis CI, Coveralls is free for open source projects and they do have paid options that supports private repositories. It does support several other CI platforms if you’re not using Travis CI.


Service Breach Time on Cases

by Patrick Connelly posted on July 29, 2015

Service Level Agreements (SLAs) are very common in the support industry. Salesforce makes these very easy to apply and manage via the built in Entitlement Processes. These entitlement processes will generate Case Milestones that are associated with your case. These milestones will have a Target Date that shows you when your Case Milestones have to be completed. Typically the date itself is fairly difficult to use however if you convert this into the number of minutes remaining then you get a tangible count down for an action that has to be done on the case. This number is called your Service Breach Time (SBT).

Unfortunately there is no easy way to transfer the Target Date from your Case Milestones to your Case and generate your SBT. These fields cannot be pulled into a formula and you cannot write triggers against Case Milestones. You can however use Apex to get the data onto your Case object.


Travis CI and Salesforce

by Patrick Connelly posted on April 22, 2015

Recently I started working on a project that required a Salesforce CI build system. This has not been a problem for me in the past because I’ve always had a Jenkins host that was setup and maintained by our admins. However, this is a public facing project and I needed something that everyone contributing could have access to.

Travis CI

Travis CI Logo

I had heard of Travis CI before, but had never had a chance to look into it. Travis CI has most of the features that you would expect from any hosted CI solution, but where it drew me in was it’s pricing. It’s free. Well, it’s free if you’re using it for a open public project on GitHub (which I happen to be doing). They do have support for private GitHub repos, but you will have to pay to access them.

Solenopsis

Solenopsis Logo

Solenopsisis a project that Scot Floess and I have been working on for several years and it has been doing all of the deployment work for our team since it’s inception. Solenopsis is an extension of the Force.com Ant Migration tool that has a bunch of fancy Ant and Python scripts to help deploy code and manage all that pesky XML.

We’ll be using Solenopsis to deploy to Salesforce via Travis CI. While I use Solenopsis to pull data down and push it back up during development, there is no requirement on the end user using it in order to get the code in the repo. The only “requirement” is that is in the src directory so that we can use other directories to hold our build scripts and other build requirements. If you do use Solenopsis for personal it will make some things easier such as building out the .sfdcignore file which may be needed depending on your configuration.


Trailhead Modules: My Favorites

by Patrick Connelly posted on March 19, 2015

I’ve blogged previously about Trailhead and some of the new modules, but I thought I’d take the opportunity to write about two of the modules. Both the Change Management and Apex Testing are near and dear to my heart.


Web services development on Salesforce

by Patrick Connelly posted on March 09, 2015

Several years ago, I wrote a blog post on developing web services on Salesforce. When helping someone in the IRC channel with web services, I realize that the article was outdated and does not follow some of the design patterns that I have learned after spending a lot of time with web services

What are Web Services?

Let’s start with a little background. Web services are Apex code that you expose out and can consume with either SOAP or REST. Typically this is used to expose complex business logic in an easily consumable way. For example, you could use a web service to combine together an account with all of it’s contacts and return them in a single call. In this article we will be covering SOAP endpoints, but most of the principles also apply to REST endpoints.


Storing Schema RecordTypeInfo in Apex

by Patrick Connelly posted on March 04, 2015

I was recently helping a friend with some Apex Controller work for a new VisualForce page, and ran across this error being displayed on the page.

Not serializable: Map<Id,Schema.RecordTypeInfo>

It was weird because it did not appear to be anywhere in the debug logs and it did not email her that an exception occurred anywhere.


Bitwise operations in Apex

by Patrick Connelly posted on February 17, 2015

A couple of days ago a friend of mine was asking about how to do bitwise math on Salesforce in Apex. I didn’t know how to do it on the platform so I decided to give it a shot.

NOTE: None of the topics covered here are specific to Apex or the Salesforce platform. These concepts extend to most languages. However, the code examples below have been tested and verified on the Salesforce platform.

What are bitwise operations?

Bitwise operations are operations that deal with numbers on a binary level. You see this type of operation mainly in lower level programing languages where you have limited resources and need to store lots of information in a small amount of space. For these examples we’ll be using the match details from DOTA 2 output. This allows for Valve to return a single number to represent lot of information.


Humblemug – My first node module

by Patrick Connelly posted on February 14, 2015

I have been working on migrating a site that I designed off of HTML with lots of javascript into a node.js app. The site has very little in the way of user interaction and mainly just displays dynamic data out to the users. This data is pulled from a number of sources but because it’s pulled client-side it’s terrible for SEO (I was young and should have known better).

One of the issues I encountered when migrating this site is that they have a gallery page that pulls data from a SmugMug album. When this site was originally written, SmugMug only had an XML based API and to make it so that JavaScript would play nice, I had to write a php wrapper that would pull down the XML and re-host it on the same domain. I sure as heck wasn’t going to tarnish my pretty little rewrite with PHP. So I tried to find a node module for SmugMug, and much to my surprise, couldn’t. And with that, Humblemug was born.


Mobile SDK 3.1 released

by Patrick Connelly posted on February 13, 2015

At the end of last year, Salesforce released the Mobile SDK 3.0 which added quite a few new features. Now, they’ve released the Mobile SDK 3.1 with some really nice new features. I have not had a chance to dive into the Mobile SDK prior to this release, but I think it’s made some great progress and should be something to give a try of.


Salesforce Trailhead: New Modules

by Patrick Connelly posted on February 03, 2015

At the 2014 Dreamforce, Salesforce announced Trailhead, their new platform for learning all about the Salesforce platform, and I have to say it’s pretty great. Anytime someone asks me how they can get started with Salesforce, “Trailhead” is pretty much the first thing out of my mouth. Well that and the IRC channel.

It’s been a couple of months now since Trailhead was released and we’re finally getting new content, and a little bit of updated content for some of the older modules. In addition to these changes the platform seems to have gotten better about it’s error messages when you fail a challenge.


Fun with maps and sets

by Patrick Connelly posted on January 26, 2015

While working on Apex, I discovered an interesting behavior with Maps and the keySet method.

Problem

class TestData {
	public String data;

	public TestData() {}

	public TestData(String data) {
		this.data = data;
	}
}

Map<String, TestData> dataMap = new Map<String, TestData>{
	'foo' => new TestData('foo'),
	'bar' => new TestData('bar')
};

Set<String> keySet = dataMap.keySet();
System.debug(keySet.size()); // 2
System.debug(dataMap.size()); // 2

keySet.remove('foo');
System.debug(keySet.size()); // 1
System.debug(dataMap.size()); // 1

This code does not behave how you would think. If you remove an item from the keySet set it also removes it from the dataMap. What I believe to be happening here is that the keySet method is returning a reference to the key set of the dataMap.


Displaying Salesforce Test Status in screen using JSforce

by Patrick Connelly posted on September 29, 2014

This post will probably only be useful to one other person out there, but it was a fun exercise and thought I’d at least share my output.

One of the biggest challenges I have when running tests is that I will often forget they are running and leave them completed for a while before I go back and remember I ran them. This mainly happens when I’m running an entire class worth of tests and have 5-10 minutes to kill. When first learned about JSforce and it’s cli capability I was in love! So I set out to make it so that the current testing status is displayed inside of my screen session. At the end of it all this is what I came up with:

Screen status


Why developers should go to Dreamforce, and how you should prepare.

by Patrick Connelly posted on August 08, 2014

With Dreamforce just around the corner, it seems appropriate to do my list of reasons why developers should go to this conference. Over the past couple of years, Salesforce has really stepped up their game in bringing more to the conference for developers. So, why should you go to Dreamforce (or why should you send your developers)?


Intro to Apex: Auto converting leads in a trigger

by Patrick Connelly posted on July 23, 2014

Over the past couple of weeks I have seen several posts on the developer forums about writing a trigger to auto convert leads based on some criteria. Since this seems to be a pretty common topic, I thought I’d turn it into my first “Intro to Apex” blog post. In this post I am going to introduce a trigger that converts a lead and the test for this trigger. I am going then break down each line of the trigger and explain what it does and why it is there.

NOTE: This is a very basic trigger. If this were to be used in an environment where there was more than just this functionality in the trigger, I would classify this trigger to control the order of operations.


Using Git with Salesforce and distributed teams

by Patrick Connelly posted on July 21, 2014

Introduction

I’ve been asked several times (and have presented a couple of times) on how our team handles doing Continuous Integration (CI) and Continuous Deployment (CD) with a distributed team. However one of the points that I’m always asked is specifically how we use Software Configuration Management (SCM) with this processes. For this blog post I’m going to do a deep dive into our process.

NOTE: This process is by no means the end-all-be-all process for everyone. This is just what we have come up with (generalized for public consumption) over several years of developing on the Force.com platform


The best feature in Salesforce Summer '14

by Patrick Connelly posted on June 26, 2014

Ok, so it might not be the BEST feature ever, but it is a feature after my own heart.

If you’ve ever done anything with pricebooks, you know how painful they can be. And worst of all how you cannot create a Pricebook2 entry in a test. This means that you have to pull a Pricebook2 from your orgs data which means you have to enable the dreaded SeeAllData.


Snapshotting objects in Salesforce with apex

by Patrick Connelly posted on May 20, 2014

A common issue that we have is a need to see information about Cases when it is created. We do this to do some analysis about how a case changes (primarily to verify how good our automated tools are working). To achieve this, we made a generic snapshot object that will store a JSON version of our data. We chose JSON for it’s portability and it’s ability to dump into other systems.

The Object

To start out we’ll need a place to put this data, so we created the object with the following fields. Download object.

  • JSON_Data_{0-9}__cRequired – These are several LongTextAreas that stores json data
  • Object_Name__cRequired – This is the name of the object that was snapshotted
  • NameRequired – An auto number, just used for identification
  • Case__cOptional – This is used for our case specific snapshot to link a snapshot back to a specific case

Sending pushover messages via Electric Imp

by Patrick Connelly posted on January 02, 2014

I recently got an Electric Imp april board and developer card. I’m really digging it and am planning on making a monitoring solution for my garage (including doors and freezer temps). In addition to reporting the data back via the agent, I wanted to add the ability to send a pushover notification to my phone on events. I wrote a quick method to do this, and thought it might be useful to others.

//Agent code
function send_pushover(title, message, priority) {
    local url = "https://api.pushover.net/1/messages.json";
    local token = "XXX_TOKENGOESHERE_XXX";
    local user = "XXX_USERGOESHERE_XXX";
    local headers = { "Content-Type": "application/x-www-form-urlencoded" };
    local data = {
        "token": token,
        "user": user,
        "message": message
        "title": title,
        "priority": priority
    }
    local body = http.urlencode(data);
    local response = http.post(url, headers, body).sendsync();
}

//To use, send_pushover("My title", "My message", 0)
//For more on priority see https://pushover.net/api#priority

Even better remote notifications with Irssi

by Patrick Connelly posted on July 26, 2013

Last month I wrote a Irssi plugin that pushed messages from Irssi to Beanstalkd. I was pretty happy with it, but I wanted more. So, I’ve improved it. The new version pushes in a slightly more normalized json payload to one of two beanstalk tubes. The tubes are configured for here and away. Then the python script that consumes them either displays it via a notification pop up, if sent to the here tube, or to pushover if sent to the away tube.


Deleting all scheduled jobs in Salesforce with CasperJs

by Patrick Connelly posted on July 26, 2013

Preface

In a previous post, I talked about how to log in to Salesforce with CasperJs. At the time I did not have a good example of what to do next with it. Well, this week I had a need that is something that other people can relate to.


Logging into Salesforce with CasperJs

by Patrick Connelly posted on July 09, 2013

Preface

Anyone that has ever had to deal with editing multiple Entitlement Processes in Salesforce will know the pain of having to do this in multiple environments and making sure you don’t fat finger this manual process. In the past when I’ve had to do this, I’ve either sucked it up and did it manually, or did it with Selenium. I wasn’t a big fan of either of these solutions since I’m a command-line kinda guy. That’s when I was told about CasperJs and I think I’m in love.


Better remote notifications with irssi

by Patrick Connelly posted on June 28, 2013

This has been deprecated in for the new script and configuration.

History

As I wrote about a long time ago I use to use a custom script with irssi to push to mumbles. Well, mumbles has gone defunct and I couldn’t really find a good growl client for linux. Plus with me traveling into the office weekly, it’s just not going to work well since growl is more push notification. So this lead me to research a true messaging system to try it.


Download and launch an Elluminate session from the command line

by Patrick Connelly posted on January 07, 2013

We use Elluminate Live! for some of our meetings, and it has always bothered me that I have to launch the browser to use Elluminate especially for reoccurring meetings. So one afternoon I set out to fix this problem. I wrote the following script and have been using it for about a month now without any issues. You can set the parameters at the head of the script if you have a reoccurring meeting you want to use, or set the parameters at run time (or in an alias for multiple reoccurring meetings) if you need too.


Auto watch a directory and rebuild the repository when an rpm is added/updated

by Patrick Connelly posted on December 19, 2012

Today I started setting up the repository for people to use to install the Solenopsis rpm. The problem is I want to be able to build the rpm (via Jenkins) and push it to a remote server and automatically have the repo rebuild when it sees an rpm updated or added to the directory.

To do this, I wrote a small python script that can be run and backgrounded. It sends a pushover notification and runs createrepo against the target directory.


Nulling fields in Salesforce with SoapUI

by Patrick Connelly posted on August 26, 2012

The Problem

The other day I came across a problem where sending in a blank field to Salesforce via SOAP was not nulling out the field. Instead, the enterprise WSDL was treating this as if nothing was sent, and therefore not updating the field at all. This make sense. If you were to send a sparse data structure over with only fields you want to update, you wouldn’t want to either have to provide the current value of every field or have them all nulled out. So, how do you null out a field with SOAP via the enterprise (or partner) WSDL in Salesforce?


Dynamic dependent picklists in Salesforce

by Patrick Connelly posted on July 09, 2012

One thing that comes up a lot in the in the #salesforce IRC channel is doing dynamic Visual Force driven off of picklists. So, let’s buckle up and get to it.

Data Model

In this simple example we are going to make an extension to the case page. On this page we are going to us a custom Product/Version object to display on the page. The product list well be determined on the start/end date of the product. And the version will be driven by the currently selected product. Product

  • Name – The name of the product
  • Currently_Supported__c – Formula based on StartDate__c and EndDate__c (Integer version of a boolean)
  • StartDate__c – The date the product should be shown (Rollup min from the version)
  • EndDate__c – The date the product should be hidden (Rollup max from the version)

Version

  • Name – The name of the version
  • Currently_Supported__c – Formula based on StartDate__c and EndDate__c (Integer version of a boolean)
  • StartDate__c – The date the version should be shown
  • EndDate__c – The date the version should be hidden
  • Product__c – The product the version is related to

Scheduled actions in Salesforce with Apex

by Patrick Connelly posted on May 26, 2012

Scheduled actions in Apex are great to use when you need to have a section of code run at a particular time in the future and Time-Based workflows will not work. In the example below I’ll talk about how to schedule code to run at the first of every month, in addition talk about some constructs you can use to make your life easier when you have to redeploy/change this code


Salesforce and soapUI – Using the default query method

by Patrick Connelly posted on April 13, 2012

In a previous post I discussed how to test Salesforce webservices with soapUI. In this post I will show how to use the “default” methods inside the enterprise WSDL.

Logging In

First we need to login to Salesforce and get our session Id. Under the SoapBinding list, expand login and choose Show Request Editor. After opening the request editor we need to remove the extra headers we don’t need, and fill in our username and password.


Reducing Salesforce SOQL queries by using static variables

by Patrick Connelly posted on April 04, 2012

The more moving pieces you have with triggers and classes the more you want to reduce the number of SOQL queries. One way to do this is to have Utility classes that do a lot of the heavy lifting. The problem with this is that you don’t want to call a utility method that does a query every time, because if you call it from different triggers you’ll end up with multiple calls. This is where overloading static variables can come in.

The Problem

Lets say you have a trigger on a Contact that needs information from our mostly static MyObject__c and then the Contact trigger then updates a Case. The Case trigger also need information from the MyObject__c. Normally this would require two SOQL queries even if it was in a utility class. We can use some of the built-in functionality in Apex to overload a static variable.


Classifying Triggers in Salesforce

by Patrick Connelly posted on February 13, 2012

Anyone that has ever had multiple triggers on objects in Salesforce knows that it can be very painful to manage them. Because of the way Salesforce chooses to run the triggers your code can be run in a non-deterministic order. In addition to this, having to sort through multiple files to find the one piece of code you are looking to update can be painful.

To combat this, you can take your triggers and condense them down into a single trigger and a single class. Inside this class you would have a method containing each of your individual triggers.


Vim and Salesforce development

by Patrick Connelly posted on February 09, 2012

Since I switched over to using vim as my primary mode of Salesforce development, I’ve been asked several times how I’ve configured vim. Well, it’s about time I show the man behind the curtain. My primary vim config file is quite large now, but I’ve condensed it down to the parts that I think are most pertinent to Salesforce development.


Salesforce and soapUI — Testing WebServices directly

by Patrick Connelly posted on February 03, 2012

In a previous post I talked about writing webservices for Salesforce. In this post I’ll discuss how to test your webservice with soapUI without having to write any additional code.

Getting soapUI

You will need to install the Open Source version of soapUI from their sourceforge. Go ahead, I’ll wait…


Creating Web Services in Salesforce

by Patrick Connelly posted on January 06, 2012

This article has been updated to show lessons learned over the past three years. The content of this article is still relevant, but is a little out-dated.

Preface

At my current job, we have several external systems that interact with Salesforce, and they do so through web-services. This document will cover what I have learned in regards to web-services, caveats with them and common pitfalls.

Overview

The goal of our web-services is to provide a single point of entry for each major object represented in Salesforce. A major object would be Account, Case, Case Comment etc. The reason this is differentiated is that for instance, Case Groups would under the AccountAPI since they are a minor object. Each web-service consists of two parts. First the actual web-service class which holds the externally facing methods and from which the WSDL is generated. The second part is that of the util class which holds all of the logic and is reusable.