Access Heroku PostgreSQL Database Locally using Docker

How to use Heroku Postgres Database from any third party application or local server

Heroku is a Platform as a Service (PaaS) provided by Salesforce and one of my favorite place to jump and spin off any third party application, which can work seamlessly with Salesforce.  Heroku also provides free PostgreSQL database which can be used by your application.

Sometimes you may be in need to use this cloud based free PostgreSQL database offered by Heroku in third party application or your local Server.

I was able to do it very quickly and easily and want to make sure would not forget in future, so here is the post. Complete source of this blog post can be found on my Github repository.

One important point to note here, local server must support SSL i.e. https. I have written some posts in past to show how SSL can be enabled in tomcat server or nodejs. This time I wanted to check how it can be done in Docker.

I always use Docker if I need to use Jenkins or any other server. Instead of maintaining all servers individually, it is easy and convenient to use container like docker and control servers or applications from there.

First step, of course is to install docker and run it. Next, create a Heroku application and enable PostgreSQL add on. After that, clone this Git repository. Continue reading “Access Heroku PostgreSQL Database Locally using Docker”

Introduction to Lightning Test Services with Jasmine

Complete Source code and video of using Lightning Datatable Component and Jasmine in Salesforce

In previous post, we discussed what is Jasmine and simple hello world program to see how it works. In this blog post, we will discuss how Jasmine can be used in Salesforce to test Lightning Component’s Javascript code.

Note : Everything we are discussing here is completely covered as part of Live coding in Apex Salesforce Saturday organized by Amit. Would like to thank Mohith for his support and answers during the demo. It also shows How SalesforceDX can be used daily by developers to perform development.

Jasmine and Mocha support is provided as a part of Lightning Test Service (LTS) by Salesforce. Jasmine and Mocha, both are well known and industry wide solution accepted in Javascript world. of course, Salesforce don’t want to stay behind in terms of its offering to developers thats why we have new baby in town – Lightning Test Service (LTS). Continue reading “Introduction to Lightning Test Services with Jasmine”

Getting Started with Jasmine Test Framework

Introduction to Jasmine framework and getting started with Behavior Driven Development (BDD) testing, along with Complete Source code and Video

Jasmine is a Javascript Testing framework which starts with behavioral specifications as a basis for writing test cases. To put it another way, you can consider user stories as a reference for write test cases. Each user story in your project can have one or more Jasmine test cases.

Majorly, Jasmine is made up of three functions

  1. describe
  2. it
  3. assertions (expect)

Like standard frameworks, it also has setup method and tear down methods

  • beforeEach() – Setup Method
  • afterEach() – Teardown Method

For the sake of simplicity of post, I would not discuss much in detail. However, you can navigate to official Jasmine guide for deep dive. Continue reading “Getting Started with Jasmine Test Framework”

Implementing Custom Apex Adapter for Salesforce Connect

Complete Source code and demo of implementing Custom Apex Adapter for Salesforce Connect

As you might already know, using Salesforce Connect, we can display external data in Salesforce without physically creating record. Before Salesforce Connect, we had few options like Visualforce, Canvas etc. There are few options available in Salesforce Connect to show data like using protocols OData 2 or OData 4, cross org adapter , custom Apex adapter etc.

There could be scenario, like you already have license for Salesforce connect and want to use it to expose external data inside Salesforce. If you think about any custom solution using Lightning component or Visualforce, there could be many considerations and most important would be displaying data on user interface.

Using Salesforce Connect in above scenario will cut down your most of effort. Your data would be exposed as External Object and you can use it just like custom object. Just imagine, how cool it would be that you would not need to write a single line of code for data presentation.

Now, here your challenge comes. It is pretty much possible that external data does not support OData protocol. And you don’t have necessary middleware tool available to perform transformation and expose it as OData. It doesn’t mean that you cannot use Salesforce Connect. One of the feature of Salesforce Connect is writing and using Custom Adapter using Apex. Continue reading “Implementing Custom Apex Adapter for Salesforce Connect”

Creating Lookup field in External Object

Author posted by Jitendra on Posted on under category Categories Salesforce and tagged as Tags , with 1 Comment on Creating Lookup field in External Object

How to create a lookup field in Salesforce External Object

This is going to be very short note for readers and pretty much possible that you already know about problem and its solution. However, lets discuss problem first.

On External Object, we do get an option to create a lookup field. It looks very straight forward first, that create a lookup field and populate value in it. Below image shows, what happens when you try to populate newly created lookup field on External Object.

Lookup Field in External Object - Not Working
Lookup Field in External Object – Not Working

Did you observed, that Lookup field on External Object does not retain any value in Salesforce? Salesforce should have given some proper error message either while creating this field or after updating record.

 What is External Object in Salesforce ? This is kind of virtual object which does not exists in your Org. So, you created a field on Object which does not exists and then tried to populate it, what else you could have imagined ?

Resolution of this situation is very easy and would make lot of sense. Same solution applies to External Lookup field as well in Salesforce. All you have to do is, create a new field in Source system of type text first (length 18) and Sync your External Data Source so that new field will appear in your / destination Org. Now edit field’s data type to lookup or External lookup and it will work as expected.

Considerations and Best practices for Salesforce Dataloading

Although we are doing data loading in Salesforce from ages, its very common to miss some steps or considerations. Therefore thought to list some of best practices and considerations I follow before or during data load process.

Salesforce Dataloader
Salesforce Data loader Considerations

Continue reading “Considerations and Best practices for Salesforce Dataloading”

Trailhead Widget for your Website

Author posted by Jitendra on Posted on under category Categories Salesforce and tagged as Tags with 14 Comments on Trailhead Widget for your Website

Show your hard earned badges by adding Trailhead Widget on your Website or Blog

Here it comes, Christmas goodies for Trailhead lovers. If you own WordPress, blogspot or any website, use this Trailhead widget to show and brag about all your badges. Badges,  which you have earned by completing challenges on sleepless nights, on airport, during commute or over the weekends. What could be the best way to show Trailhead profile summary other than widget?

Will it impact performance of my website

All computations are done outside of your website and Javascript execution is asynchronous, which will make sure website rendering is not blocked by this widget.

How to use it

Step 1

Identify the URL of your Trailhead profile. Make sure you are not copying URL of success community. Below image shows steps to get Trailhead URL. We just need end part of URL, after last forward slash. Continue reading “Trailhead Widget for your Website”

A Tale of Governor Limits and Solutions in Salesforce

Thrilling story of Salesforce Technical Architect on a quest to solve application problems and avoid governor limit errors

This is a work of fiction. Names, characters, businesses, places, events and incidents are either the products of the author’s imagination or used in a fictitious manner. Any resemblance to actual persons, living or dead, or actual events is purely coincidental.

Ha ha ha joking.. its combination of many real stories of my previous projects and few readers might be from my team itself 😉 . Leave comment my brave team mates if you are able to co-relate !!!

I tried to summaries as much as possibilities about governor limit errors and way to get out of it. Most of scenario described below may not be the first choice of Technical Architects however because of many reasons like budget, resource skill, tools available and compliance, bad decision could be taken which causes ripple effect on Salesforce scalibility.

Before start, I would encourage readers to leave comment on post and let everyone know in this suspenseful story, did you catch governor limits and Solution already before its exposed ? In this blog post, answers are mostly in invisible/white font which would not be seen until you highlight it. Its for few readers who don’t want spoilers. 

Let’s start a story. Continue reading “A Tale of Governor Limits and Solutions in Salesforce”

Import and Export Records using Salesforce DX

Author posted by Jitendra on Posted on under category Categories Salesforce and tagged as Tags , , with 4 Comments on Import and Export Records using Salesforce DX

Using Salesforce DX to Export and Import records into regular Salesforce Instances without dependency on developer hub org

In today’s continuous integration solution built for Salesforce, if you need to load sample data into Salesforce then either we use command line dataloader or custom tool built to import export records.

With Salesforce DX, we can import and export records right from Salesforce DX. Again, if you are new to Salesforce DX, then first read this blog post to quickly understand what is Salesforce DX. 

We don’t need Developer Hub or Scratch Orgs to use Salesforce DX for import and export. In this blog post, I have used my regular developer org for demo.

First step as always, to make sure if Salesforce DX CLI is connected to your Org or not ? If its not connected then use below command to connect and give alias which is easy to remember. Continue reading “Import and Export Records using Salesforce DX”

Use Metadata API with Salesforce DX

How to use SalesforceDX to deploy metadata in Sandboxes or Non-Scratch Salesforce instances

If you have existing VCS which stores metadata information about your Salesforce instance in old format, dependent on package.xml and you want to use Salesforce DX then this blog post is for you. As you might already know, Salesforce DX does not need package.xml and can automatically detect changes in your Salesforce instance, therefore new Salesforce DX project format is different. In this blog post we will see, how Salesforce DX can be used without enabling Developer Hub and using Salesforce DX with normal Salesforce instances.

There are two solution to this problem

  1. Keep using old Project format and use Metadata API to retrieve and deploy
  2. Convert old project format to Salesforce DX project Format

Continue reading “Use Metadata API with Salesforce DX”