How to Prepare Environment for Salesforce SOAP API Development

In this article, we will discuss the detailed steps on how to set up the environment for API Development in Salesforce with all prerequisites tools & permissions.

Before starting with API development for Salesforce, we need to ensure that all prerequisites are properly installed and configured, this will save lots of significant development time by avoiding the environmental issue.

In this article, we will discuss the detailed steps on how to set up the environment for API Development in Salesforce with all prerequisites tools & permissions.

The very first tool that we would be needing is “Postman API Client”. It is the most important tool for API development as it is the collaboration platform that allows sending REST & SOAP Requests quickly & easily. It also provides features to inspect API status code, response object, response time and much more.

“Postman API Client” is a must to have tool for any developer targeting API development across any platform or technology stack. In this article, we will look into API development for Salesforce specifically.

Download & Install “Postman API Client”

We can follow the steps below to download & install the “Postman API Client”-

Step-1: Google “getPostman.com” or visit the link https://www.getpostman.com/

Step-2: Click on “Download the App”

Step-3: Click on “Windows 64 bit”, this selection depends on the type of machine you are running on

Step-4: Save the “.exe” file to the disk location

Step-5: Run the “.exe” with admin privileges

Step-6: Wait till the installation is over

Step-7: If you already have an account with Postman use it to sign in

Important Note: It is important to note that all the collections you created with Postman are saves to their cloud and can be accessed on any device across any part of the globe.

Step-8: OR you can create a new account to manage your collections

Step-9: Once Postman Client is launched, you can create a new collection for your API queries by clicking “New Collection”

Step-10: Give the name to the collection lets’ call it “Salesforce APIs”

Step-11: Click the “Create” button to add the collection to the Postman Client

Step-12: And we can see a new collection is added to the Postman Client

Enable Salesforce User Permissions for API Access

Step-1: Search for “Users” under Setup

Step-2: Click on “Users” under Users Menu

Step-3: Look for the user profile you would like to enable API access. Let’s pick up “Bansal Prashant” who is also a “System Administrator”. Since this the admin profile so the “API Enabled” permission would be already enabled but we can still the process on how we can reach it. Click “Edit” to edit the profile

Step-4: Now if you scroll down the edit profile screen till you find a section called “Administrative Permissions”. Under “Administrative Permissions” we need to locate “API Enabled” permission and check it if it not already checked. This permission will enable API access for this User Profile and after that API request to Salesforce will go under User Authentication for this User Profile.

Reset Security Token

This step is optional for those who already have their security tokens, but if you don’t have it, you can follow the steps below-

Step-1: Under User Profile Menu at the top, click “Settings” the get to the User Personal Information Menu

Step-2: Under “My Personal Information” menu, click “Reset My Security Token”

Step-3: On the “Reset Security Token” screen, click “Reset Security Token” button

Step-4: This will send the email to the user’s registered email id with security token details

Step-5: If we analyze the email received from Salesforce we can see the subject as shown

Step-6: The user will receive the security token email from support@salesforce.com, so make sure you keep this email id safe from spam

Step-7: In the email, we will see the security token details as shown

Generate Web Services Description Language (WSDL)

WSDL is important for API Developers as it gives a quick reference about the existing metadata regarding the Salesforce Org. This reference could be extremely helpful when building API Calls which may call body, input parameters, filters, SOQL queries and much more.

We will see the steps to generate the WSDL file from the Salesforce schema. Make you generate WSDL file every time the Salesforces Org Metadata for updated to keep an updated reference for the development-

Step-1: Search for “API” under Setup

Step-2: Click “API” under integration section

Step-3: Since we are going to work with Salesforce Org within my Organization so it is always a recommended approach to generate “Enterprise WSDL”. Click on “Generate Enterprise WSDL” link to launch “Generate Enterprise WSDL” screen

Step-4: Click on the “Generate” button to initiate the WSDL generation

Step-5: Soon enough you will see the WSDL launched in a browser window, where we can read the WSDL specifications & details

Step-6: You can save the WSDL detail in the file for the reference later

Step-7: It is a rather long file and get to the end in a couple of scrolls, scroll it down you would see the SObject metadata definitions for all Standard as well as Custom objects

Hope you enjoyed this article. Please leave your comments to let me know how you do like the content and how you do find it helpful to learn the topic.

How to Add Lightning Apps for Salesforce SObjects (No Code Approach)

In this article, we will discuss a no-code approach of adding a lightning app for our Salesforce Org. This approach is helpful to launch any Salesforce Object (Standard or Custom) as an application without using any code.

In this article, we will discuss a no-code approach of adding a lightning app for our Salesforce Org. This approach is helpful to launch any Salesforce Object (Standard or Custom) as an application without using any code.

This demo includes the following steps:

Create a Custom Object

We can add a new Custom Object “Students” as shown in the steps below-

Step-1: Click on “Object Manager”

Step-2: Click “Create” and select “Custom Object” to launch a “New Custom Object” screen

Step-3: Specify Label for the object, let’s call it “Students”

Step-4: Select “First Name” as a record identifier. This is just a demo so anything works just fine but in a more sensible solution I would rather choose “Student Id” an auto-generated number as a record identifier

Step-5: Select any “Optional Feature” you deemed fit for the Object

Step-6: Select any “Object Classification” feature as you deemed fit for the Object

Step-7: Click “Save” to submit the changes

Step-8: After step-7 we will see the details section of the newly created object

Step-9: We can see the API name for this newly created object, this API name will be helpful when we will write Apex code or other Declarative Solutions based on the “Students” object

Add a new Tab for “Students” Object

We can add & assign a new tab to the “Students” object as shown in steps below-

Step-10: Search for “Tabs” in Setup

Step-11: Select “Tabs” under “User Interface” navigation menu

Step-12: Under “Custom Object Tabs” section, click “New” to add a new tab for “Students” object

Step-13: Select the object you want to assign a tab to, in this case, we will choose “Students” object

Step-14: Click on the “Search” icon to select a style from “Tab Style Selector” screen

Step-15: Choose a suitable tab style from the “Tab Style Selector” and click “Next”

Step-16: Select all the profile you want this Tab available for, for this demo, I keep the defaults and click “Next”

Step-17: Select all the custom apps you want this Tab available for, for this demo, I keep the defaults and click “Next”

Step-18: Once the Tab is added successfully, it will be displayed in “Custom Object Tabs”

Create a Lightning App for “Students” Object

We can add a new Lightning App for the “Students” object as shown in the steps below-

Step-19: Search for “App Man” in Setup

Step-20: Click on “App Manager” under “Apps” navigation menu

Step-21: On the “Lightning Experience App Manager” screen, click on the “New Lightning App” button in the toolbar. This will launch the “App Details & Branding” screen

Step-22: Enter the app name as “Students App”

Step-23: Enter the developer name as “Student_App”, this will be helpful to locate the apps in Apex & Declarative Solutions

Step-24: Enter description as required

Step-25: Choose an Image for your app

Step-26: Select the color scheme as per branding directions from business

Step-27: Shows the preview of the Application look & feel

Step-28: Click “Next” to configure the options for the App

Step-29: Choose Navigation options as required, I will keep the defaults for this demo

Step-30: Choose Setup Experience options as required, I will keep the defaults for this demo

Step-31: Select the require utility items for the App, Utility Items are reusable components that can we with used with any app. We can add or modify items associated with the app later as well

Step-32: Click “Next” to configure navigation items

Step-34: Select the require navigation items for the App, in this case, will search for “Students” Tab

Step-35: Click “Students”

Step-36: Add “Students” Tab to the Selected Items section

Step-37: Click “Next” once you are done with the selection

Step-38: On the “User Profiles” screen, choose the user profiles that can access this App. For this demo, I want only system admins to have access to this app. Search for “Sys” to locate for “System Administrator”

Step-39: Select “System Administrator” profile that can have access to this app

Step-40: Click add icon to move “System Administrator” profile to “Selected Profiles”

Step-41: Click “Save & Finish” to finish configuring the App

Step-42: That is all to create and set up the new app for “Students” Object. Now if go to “App Launcher” screen

Step-43: We should be able to see the “Students App” Icon

Step-44: When we click on “Students App” Icon, it will take us to the List View form of the Student Object

Hope you enjoyed this article. Please leave your comments to let me know how you do like the content and how you do find it helpful to learn the topic.

How to Enable Intellisense Support for Salesforce Apex Code in Visual Studio Code

In this blog, we will look into the detailed steps of how to enable Intellisense support for Salesforce metadata. Enabling this feature will increase the code writing capability and accuracy exponentially for a developer.

I am sure we all know how painful it could be writing code without Intellisense support for the code editor. So it is really important to see how we can enable this feature for our favorite code editor “Visual Studio Code”.

In this blog, we will look into the detailed steps of how to enable Intellisense support for Salesforce metadata. Enabling this feature will increase the code writing capability and accuracy exponentially for a developer.

Salesforce provide intellisense support by implementing “Apex Language Server” through Salesforce CLI. “Apex Language Server” is dependent on java as its prerequisite.

Lets’ start by downloading and installing Java Runtime Engine that we can download from Java Development Kit

Download Java Development Kit

Step-1: Download the JDK version as shown above

Step-2: Once the download is complete, we can install the JDK by using Administrator privileges

Step-3: Click Next

Step-4: Keep defaults and click Next

Step-5: Wait till the installation files copied

Step-6: Keep defaults and click Next

Step-7: Wait till the installation completes

Step-8: Click Close to complete the installation

Configure User Settings in Visual Studio Code

Launch Visual Studio Code and follow the below steps-

Step-1: Use shortcut “Ctrl + Shift + P” to launch the Command Palette

Step-2: Search for “User Settings”

Step-3: Run the command “Preferences: Open User Settings”

Inside the User Settings follow the below Steps-

Step-1: Search for a User Property “Java: Home”

Step-2: Locate the property “Salesforcedx-vscode-apex > Java: Home”

Step-3: Specify the installation path of JRE folder, in my case it is “/Program Files/Java/jre1.8.0_231”

As soon as we are done with the steps above we need to follow the steps below-

Step-1: Click on the output Tab in the terminal window

Step-2: Select “Apex Language Server” from Output down as shown, if you find message coming through that mean “Apex Language Server” is up and running

Now next thing to do is to refresh sObject Definitions from Salesforce Dev Org or Sandbox to the local Definitions cache

Refresh sObjects Definitions

To refresh the sObjects Definition we need to first close User Settings Window and use the shortcut “Ctrl + Shift + P” to launch the Command Palette

Then follow the steps below-

Step-1: Search for “SFDX: Refresh SObject Definitions” command

Step-2: Click “SFDX: Refresh SObject Definitions”

Step-3: Select what type of SObject Definitions you want to refresh, I would recommend selecting “All SObject” since this will be the most effective option to refresh the definition cache all at once for the complete Salesforce Org

Step-4: After you make the selection, look for Output window in the terminal where we can see this Refresh Process started successfully as shown

Step-5: After a short wait you can look for the Output window again and if everything goes as expected you will the process completed successfully with exit code 0. Exit Code 0 means no errors encountered if it encountered any error the respective error code would have returned.

That is all for the configuration and now it is time to test if Intellisense is enabled as expected.

Test Intellisense Support

Lets’ create any apex test code to see if we get Intellisense support, here I have added a trigger as shown below-

We can see the Intellisense support available.

Happy Coding! 🙂

Hope you enjoyed this article. Please leave your comments to let me know how you do like the content and how you do find it helpful to learn the topic.

How to Troubleshoot Salesforce Process Builder Flows & Other Development Artifacts

In this article, we will look into the detailed configuration steps to enable Salesforce development environment to support debugging of development artifacts like Workflows, Database Queries, REST API Calls, Apex Code and much more.

No developer is impeccable without outstanding debugging dexterities!

Prashant Bansal

In this article, we will look into the detailed configuration steps to enable Salesforce development environment to support debugging of development artifacts like Workflows, Database Queries, REST API Calls, Apex Code and much more.

We have a couple of approaches to debug development artifacts in Salesforce, in the following sections, we will explore the configuration steps involved with each of the approaches and then finally we will see how can we modify the process to make it raise an exception.

Approach -1: Using Apex Email                             

  • Configure “Process Automation Settings”

We need to make few changes to these settings as shown in the steps below:

Step-1: Search for “Process Automation Settings” as shown below

Step-2: Click “Process Automation Settings”

Step-3: Select “Apex Exception Email Recipients” from the dropdown as shown

  • Configure “Apex Exception Email”

We need to first add a required user to the recipient list so that the user gets the error details in the email

Step-1: Search for “Apex Exception Email” as shown below

Step-2: Click “Apex Exception Email”

Step-3: Click “Add Salesforce User” to add the user to the recipient list

Step-4: This will launch the “Add Salesforce User” screen, click on the search name icon to find the Salesforce User Directory

Step-5: This will launch the User Lookup screen, type the name of the user you are trying to add

Step-6: Click “Go”

Step-7: If the search can find a match as per your search keyword, then it will be shown to the “Search Result” section. Click on the user name you like to add as a recipient

Step-8: This will close the lookup window and copy the selected user in the name textbox

Step-9: Click “Save” add the selected user to the recipient list

Step-10: After the user is added to the recipient list, it will look like as shown

To utilize this approach first we have to generate the exception and then we will perform a detailed analysis of the error information received in the email

To generate the exception please refer to the “Generate Exception for Demo” section down below. Here I am copying the screenshot of the error generated from this section:

  • Analysis

Now we will analyze the error information that we received as part of debugging through Apex Email

We can see the email received as shown below:

Step-1: We can see the subject line giving some idea on the source of exception, as we can see it the flow by the name “Update_Contact_Details” throws this exception

Step-2: We can see the email id that Salesforce used to send this error email to the recipient

Step-3: We can see that error occurred since “Account.Primary_Email__c” returns a null value, which is expected as we have removed the account information associated with the current contact record.

Step-4: If we analyze the email body we can see some obvious information like “Flow API Name: Update_Contact_Details”. With this information, we can conclude that this error occurred in flow with the name as specified in Flow API Name

Step-5: We can see under which user credential this flow executed, like in this case this flow was executed by user “Prashant Bansal”

Step-6: This is the most important piece of information where Salesforce is informing that both Email & Phone fields could not be resolved for obvious reasons

Approach -2: Using Developer Console Logger

Developer Console Loggers is a very powerful mechanism to debug almost every kind of functionality on the Salesforce Platform. We will analyze the exceptions occurred as shown in the followings steps:

  • Configure Log Level

To track exceptions from different sources (Apex, Database, Workflows and so on) we need to configure the log level within Developer Console > Debug Menu as shown below:

Step-1: Click “Developer Console” to launch developer console

Step-2: Click on the “Debug” menu

Step-3: Click on “Change Log Levels”

Step-4: On “Change Log Level” screen, click on “Add/Change” under “General Trace Settings for You”

Step-5: On the “Change Debug Level” screen, click on “Add” to add a new debug level with custom configuration

Step-6: Enter the name of new Debug Level, lets’ call it “Process_Builder”

Step-7: This is important to understand that we can add the level and configure each of the sources and define what level of tracing we need.

We can reach out to the details of “Debug Log Categories” and “Debug Log Levels” by following Salesforce documentation at Debug Log Levels

Step-8: In our case, we need to trace exception coming from Workflows, so in this custom Debug Level we will turn off tracing for all log categories except “Workflow”. We can turn off tracing by selecting “None” from the dropdown on the custom debug level row. We will select “FINER” as log level which gives the best available data for exception generated on any of the Workflows across Salesforce Org

That is all we need for the configuration.

To generate the exception please refer to the “Generate Exception for Demo” section down below. Here I am copying the screenshot of the error generated from this section:

  • Analysis

Now we will analyze the error information that we received as part of the debug log of the developer console.

Once exception occurred we can see a new log entry on the Developer Console. Double click it to open the log

In this log we can focus on some important entries as mentioned below:

  • “WF_CRITERIA_BEGIN”: This log entry gives details on the name of the sourcing process (Update_Contact_Details) that causes this exception
  • “FLOW_VALUE_ASSIGNMENT”: This log entry gives details on data assignment to the flow variables, this could be useful to see what values were passed to these variables during workflow runtime
  • “FLOW_ELEMENT_ERROR”: This log entry gives the details on specific error information and can be very helpful to point us out quickly to identify the true cause of the exception
  • “WF_FLOW_ACTION_ERROR_DETAIL”: This log entry gives the details on exception statement, it is the same statement that you have seen as exception message on the User Interface

We can double click on any of the log entries to open it as a message box as shown

With this information, it will be easy to track down the exceptions occurred in Salesforce automation flows & other development paradigms (Process Builder, Workflows, Visual Flows, Apex, Database, REST APIs and much more)

Generate Exception for Demo

To demonstrate the debugging process we need to first generate an error and then we will analyze it step by step.

I would recommend you to go through the following articles I wrote earlier explaining details on how to develop automation workflows using Process Builder.

I am repeating the same steps here quickly to show you a test scenario which will end up with an error in the following steps:

Step-1: Launch Process Builder, click on “New” Button

Step-2: Add a trigger for “Contact” SObject

Step-3: Specify trigger name “Contact”

Step-4: Select trigger condition “when a record is created or edited”

Step-5: Add criteria

Step-6: Specify criteria name “Empty Email & Phone”

Step-7: Select criteria condition “Conditions are met”

Step-8: Set condition as (If Contact Email & Phone are empty)

Step-9: Add Action

Step-10: Specify action name “Update Contact”

Step-11: Select record as “Contact” SObject

Step-12: Select the action condition as “No criteria-just update the records!”

Step-13: Set contacts field with field reference of Account associated with Contact details.

Field assignment as follows:  (Contact -> Email = Account -> Email), (Contact -> Phone = Account -> Phone)

Step-14: Launch “Contact” list view

Step-15: Click “New” to add a new contact record

Step-16: Once added it will look like this

To generate the error, I have removed some of the important fields like Phone Number, Email and most importantly I have removed the value from Account Field which a lookup field and if you remember the process we defined above will try to copy Email and Phone information from the associated account to contact record

Now if I try to save the record it will trigger the process that we defined earlier and try to set the values as defined in the Add Action Step

It will fail since we have removed the Account information from the Contact record. As a result of which process try to query the Email & Phone information from a null referenced field (Account)

We will see an error similar to the one shown below:

This article holds good if you wish to debug any development artifact in Salesforce and not just Workflows.

Hope you enjoyed this article. Please leave your comments to let me know how you do like the content and how you do find it helpful to learn the topic.

How to Setup Visual Studio Code for Salesforce Development

In this post we will look into detailed steps to setup Visual Studio Code as IDE for Salesforce code development.

In the recent past, we have observed that Visual Studio Code (VS Code) is picking up popularity among open source IDEs for code development across multiple programming languages. JavaScript-based frameworks, Python-based application development, Salesforce Apex Code development, HTML, CSS based Front End development and so on are the most popular choices working with VS Code. This powerful behavior of supporting multiple platforms resides in the ability to adopt Plugins & Extension Packs that support the most popular programming languages & frameworks, and I believe Visual Studio Code has does a brilliant job so far.

In this post, we will look into detailed steps to setup Visual Studio Code as IDE for Salesforce code development. Here is the quick list of the components that we would be working through in the following sections-

  • Install & Configure Visual Studio Code
  • Install & Configure Salesforce CLI
  • Install & Configure Salesforce Extension Pack
  • Create Test Salesforce Project
  • Authorize Salesforce Org

We will discuss the individual configuration for each of the moving parts contributing to this setup in the upcoming steps-

Install & Configure Visual Studio Code

  • Click on “Download for Windows”
  • Save the setup file
  • Open the setup file by right click > Open. Please make sure you don’t use the “Run as Administrator” option since VS Code cannot be installed with Admin privileges as suggested by the following alert message.
  • Accept the License Terms and click Next
  • Click Next
  • Click Next
  • Make sure “Add To Path” is checked and click Next
  • Click Install
  • Wait till the setup completes the installation, which should be really a quick install
  • Click Finish & Launch VS Code to make sure installation works just fine

Install & Configure Salesforce CLI

  • Click “Download for Windows” depending on windows version you are running on
  • Save the CLI setup file
  • Open the setup file by right click > Open
  • Keep the defaults and Click Next
  • Keep the defaults and click Install
  • Wait till setup completes the installation, which should be really a quick install
  • Click Close to complete the installation

Install & Configure Salesforce Extension Pack

  • Launch VS Code
  • On the left most menu panel, Click Extensions Icon of press “Ctrl + Shift + X”
  • Search for “Salesforce Extension Pack”
  • Install Salesforce Extension Pack by clicking “Install” and wait till installation completes
  • Launch a new terminal by going to Terminal Menu > New Terminal or press “Ctrl + Shift + `”
  • Now we have to validate the installation of Salesforce CLI by typing “SFDX” in the new terminal. If we get the following similar outcome then we can ensure a successful installation.

Create Test Salesforce Project

  • Launch VS Code
  • Press “Ctrl + Shift + P” to see all available commands from all installed plugins & extensions
  • Search for “SFDX: Create Project with Manifest” and select it
  • Select project template as “Standard” or whatever suits you the best
  • Enter the desired name of the Project, whatever suits you
  • Select the folder location to save this project on the disk
  • And sure enough, we will get our new Salesforce project created with the manifest file

Authorize Salesforce Org

  • Launch VS Code
  • Press “Ctrl + Shift + P” to see all available commands from all installed plugins & extensions
  • Search for “SFDX: Authorize an Org” and select it
  • Select for “Org Url” Template, I will go by project default for this demo
  • Enter the Org Alias to recognize you Org by an alias, I have specified “SFOrg” as an alias for this demo
  • This process with direct you to the Salesforce Login Page, where you can specify the login credential for your Org (no matter Prod or Sandbox). Enter your credentials
  • Once successfully login to the Salesforce Org. visit the VS Code again and sure enough, we get the notifications to successfully authorize the Org.

Hope you enjoyed this article. Please leave your comments to let me know how you do like the content and how you do find it helpful to learn the topic.