While developing applications on Force.com platform using Apex, I am sure you may have been in need of debugging your code. Salesforce being cloud platform, method to debug code is very different as compared to other programming languages. In this post we will discuss all about Apex code debugging, challenges, solutions and other best practices.
Salesforce Advance Apex debugging
How many ways to debug Apex code
- Eclipse Force.com IDE
- Debug log
- Developer console
- Fetch debug log using Tooling API
This is first of many upcoming articles on evaluation of Salesforce AppExchange products. In this post we will be discussing capability of native Force.com based solution for Continuous integration. Deployment has always been one of pain point in Salesforce developement. I have worked and proposed many solutions to customers based on their requirement and budget. One of solution which got my attention recently is “Flosum” available and listed on AppExchange from this year.
I have used many traditional continuous integrations like Jenkins, Bamboo, Scheduled ANT script but all of them still involve manual intervention and most important, special skill set to setup and handle any issue arising time to time.
Let’s talk about Flosum and what makes it different at high level:
- Complete native solution built over Force.com platform
- Requirement gathering to deployment, all aspects covered
- Multiple environment management
- Easy Profile migration
- Security access to environment for each user
- Default space 11GB
- Acts as Version Control
- Supports Continuous integration and auto deployments
- Compare Complete Org with historical or current changes
- 360 reporting view
1. Salesforce Developer Tool Suite
First in my list is “Salesforce Developer Tool Suite” by concret.io.
Does it takes a lot to view debug logs i.e. via setup area or dev console. This extension is an attempt to make this use case simple, by making debug logs visible in 2 clicks, without leaving the current Salesforce tab. Plus, you get a better hierarchical view of debug logs, which are better to analyse.
I have lots of expectation from this extension as this is the one of extension which takes feedback actively (You can find discussion tab just inside app) and frequently releases new capabilities. More features, like Execute Anonymous, Code Coverage, Test Cases are in pipe, will be released soon.
Chrome extension – Salesforce Developer Tool Suite
install it from here. you can find more about this extension on company blog page.
2. Salesforce Navigator
Second in my list is “Salesforce Navigator” and I cant live without it a single day. On average, it saves more than 50% of my clicks needed for administration. My shortcut for this utility is “Ctrl + Alt + Space” and I guess this most used combination on my system. Using this utility, you can directly navigate to any setup page like Object, Apex class, Pages, Workflow rule etc.
Salesforce Navigator – Google Chrome extension
install it from here. Continue reading
In many of my previous implementations I have used advantage of Apex code running in System mode however never tried how far it can go in terms of capabilties. There is no specific Salesforce documentation which can explain that what is allowed or not allowed in System mode.
In this post, we will go through some scenario and will try to understand what really is possible in Apex System mode and when it can fail.
Before diving more lets discuss how many types of mode do we have in Apex ?
User Mode : As per this Salesforce post, all Profile level permissions, sharing rules and Field level security are enforced in Apex if it runs in User mode. Standard Controller and Anonymous Apex runs in User mode.
System Mode : Same post conforms that custom controller, trigger, Apex class, controller extension works in System mode. Means eventhough user does not have necessary profile level permission, record level permission or field level permission, but still they can perform any operation on it.
I have already written article to integrate Salesforce with other Salesforce instance around 3 years back. In last 3 years, Salesforce has changed a lot. This time I will integrate Salesforce with other Salesforce only only in 5 lines of code, can you believe it ? Check my old article, and its around 50+ lines of code with security control.
What is Named Credential ?
A named credential specifies the URL of a callout endpoint and its required authentication parameters in one definition. You can simplify the setup of authenticated Apex callouts by specifying a named credential as the callout endpoint. You can instead specify a URL as the callout endpoint and register that URL in your organization’s remote site settings. In that case, however, you handle the authentication in your code. Doing so can be less secure and especially complicated for OAuth authentication.
Long description short , “using Named Credential, we can make call out to external system without supplying username or Password”.
There are many ways to login to your Salesforce instance, using Google, Facebook, Linked, Twitter and even from other Salesforce Organization. I am sure many of readers has multiple Salesforce instances and its hard to remember password of each. We can connect every Salesforce instances and login using only one. In this post we will see, how we can login to one Salesforce from other using built in Authentication provider from Salesforce.
Throughout this article I will use term “current Salesforce instance” for Organization where I need to go after login and “Authentication Provider instance” which will authenticate user and will act as source organization for login.
First step to start with Authentication Provider is to setup my domain in your “current Salesforce instance“. This step is important so that it will display all available Authentication provider for that Salesforce instance.
Create Connected app
If you want to login from Facebook, LinkedIn or any other web application, you need to inform Salesforce that those applications are legitimate and this is very important piece of OAuth2. One of major difference between OAuth1 and OAuth2 is that OAuth2 provides scope where you can set what specific permission this Connected App will need.
Connected App also has “Consumer Key” and “Consumer Secret” which is equivalent to “username” and “password” for that App.
Other important setting, connected app has “Callback URL“. This is the URL where “Authentication Provider instance” should return after providing access. Even if somehow “Consumer Key” and “Consumer Secret” is compromised, it will return to Callback URL which is your application.
soapUI is most common tool available to test Soap based web services, it also has capability to test REST web services. soapUI can be used to test Partner WSDL, enterprise WSDL, Tooling API, Metadata API to study capability and response from Salesforce before writing any code in Java, C# or any other language. In this article we will see, how we can leverage this tool to test enterprise WSDL from Salesforce.
You can download latest version of soapUI from here.
In previous blog post, we saw that how Lightning component bundles are related to each other and how to create simple Hello World component.
In this post, we will create very simple yet powerful reusable lightning component for collapse and expand panel. This time, we will skip basics of lightning and directly start with code.
Lightning CollapsiblePanel Component – Collapsed
Lightning CollapsiblePanel Component – Expanded
We may run into scenario in Salesforce project, where we need call external web service but no need to wait for response. Response from external web service can be processed asynchronously and once processed it can be presented in Visualforce page.
Execution Flow of an Asynchronous Callout – Image from Salesforce documentation
Below code demonstrate complete usage of this.
As you might already know that next big change in Salesforce is introduction to lightning components. As technology is changing rapidly and to take advantage of cutting edge innovations in web technology, Salesforce doesn’t want to stay behind. If we see trend, all major platform has introduced component based design like Polymer, React, Web Components, Angular 2.
We will be discussing basics of Lightning components in this post and how Lightning application, component, controller, helpers and Apex controllers are connected with each other.
Lightning components are based on open source UI framework for web development. Every Salesforce organization already has aura documents available in their instance and can be opened by navigating to http://instance.salesforce.com/auradocs. You can also visit my other blog post explaining FAQ of lightning and Lightning Trailhead module.
Getting started with lightning components