Start using Salesforce DX and check out the SOQL completion in Apex in Blaze R6
One week is left before Dreamforce'17 where everyone will be talking about Salesforce DX, just because it is so great for Salesforce development that no one can ignore it! But before talking about it at Dreamforce — today we are happy to release SFDX support in The Welkin Suite for Mac, so you will even have some time to try it out before the snowball of news from the Moscone center will flood the network!
While Salesforce DX provides you with a whole set of commands (with even more arguments to remember), so you can do everything from the command line — we believe that instead of remembering all of those commands and arguments, it's much better to reserve some kilobytes of your brain's memory for something more useful, say like a couple more design patterns or best practices This is why our main goal is to provide you with a handy GUI that is shaped exactly for your needs and tasks!
Salesforce DX — Bundled CLI
As you might know, the Salesforce DX magic starts with the Salesforce DX Command-Line Interface, and this is required to be installed on your Mac before starting to enjoy all the awesomeness of SFDX, and its support in TWS. As usual, there are a couple ways to do this with The Welkin Suite:
- if you already have The Welkin Suite — you can install the CLI manually from the official website;
- if you're just installing the IDE, using the installation package from our website — the latest Salesforce DX CLI application is bundled into it, so you won't need to do anything else:
If you're installing The Welkin Suite using the installation package from our website and if you don't want to install the SFDX CLI — just uncheck the corresponding checkbox during the initial steps of the installation.
And, of course, if you already have the CLI installed, you won't need to do anything at all!
Salesforce DX — New Project Type in the IDE
Once you have the latest version of The Welkin Suite, as well as the Salesforce DX CLI, you can start exploring all of the great features provided by the symbiosis of the IDE and the CLI, and a starting point for this is a new 'DX Project' in TWS. Here and below we will highlight the corresponding CLI commands which are executed by The Welkin Suite when you perform actions in the graphical UI.
When you create a new project from the starting screen of the IDE, or from the 'Application Menu → File → New → Solution', you will see a 'DX Project' option — select it and the project creation wizard will be launched.
After you enter a name and location for your project, and press 'Create' button, you will have an option to modify a couple more options for the project. These options together, with the project name, will be passed to the 'force:project:create' command:
- Template stands for the '-t | --template' argument — a template, which is used to create a project.
- Namespace stands for the '-s | --namespace' argument — the namespace which is associated with this project, and any connected scratch orgs.
- Default package dir is the same as the '-p | --defaultpackagedir' argument — a default package directory name. Metadata items are placed inside this folder. The default value for it is 'force-app'.
After finishing the project creation wizard, the IDE will create for you an empty SFDX project — with absolutely the same structure and content, as you'd get from using the SFDX CLI itself.
So what are the differences between the regular Salesforce and SFDX projects in the IDE? Here they are:
- Information about Salesforce organizations is not stored in an SFDX project file;
- The SFDX project structure is the same that all the projects that are created via the Salesforce DX command-line interface would have;
- Information about files, which are included in a SFDX project, is not stored in a project file — the project folder and files in it defines the project content;
While you are getting a whole set of new incredible features in a Salesforce DX project in The Welkin Suite — already now you can use almost everything from the good old features of the IDE, that are available for regular projects, and we will highlight below which of them exactly are implemented in The Welkin Suite Blaze R6 for SFDX. Soon — more
Salesforce DX — Organizations Manager
Have you already learned all the CLI commands from the 'force:org' namespace? There are not so many of them (to be honest with you), but why should you be doing this if you have a great 'Organizations Manager' in front of you in The Welkin Suite! We are sure you are asking something loke, does it provide enough information to keep tracking of all your Dev Hubs, Scratch Orgs, and regular Production/Sandbox/Development environments? Let's see, but first, you'll need to enable it using the 'Application menu → View → Pads → Organization Manager'!
When you open the 'Organizations Manager' pad, it will execute the 'force:org:list' command, and it will show you all the results in a nice and clear way:
Let's start describing the pad from its main part — list of organizations. It is located in the middle part of the pad, and shows you all organizations that are stored in SFDX CLI, with a breakdown into 'SFDX organizations' and 'Regular organizations'. Under the 'SFDX organizations' you will see all of your Dev Hubs. Also at the same time, each of the Dev Hubs in the list will contain a list of related Scratch Orgs. In the list of organizations, you will see that some of the organizations are highlighted with bold — these are your default DevHub and Scratch orgs.
For all the organizations in the list, you will be able to execute some of the most common actions from their context menu, or from the toolbar, so let's go through the list of these actions:
- Add a Dev Hub or regular Organization to the list of orgs, or create a new scratch organization. We want to draw your attention that the option to create a new scratch org is available only when a Dev Hub organization is selected in the list.
- 'Delete' or 'Exclude' button deletes scratch orgs, or excludes regular/dev hub orgs from the SFDX CLI list of organizations.
- 'Make default' — allows you to mark a dev hub as a default dev hub, or a certain scratch organization as a default scratch organization. You can do this both globally, or just locally — for a current project. We will go through the usage of default dev hubs and scratch orgs in the next paragraph when we will explain how the existing TWS features are working for SFDX projects.
- Options 'Pull' and 'Push' are available only when some scratch org is selected in the list. These buttons allow you to pull/push sources of your current project to a selected organization. For both push and pull, you also have an option to make a 'force push' and 'force pull' — this translates to '-f | --forceoverwrite' argument for 'force:source:push' and 'force:source:pull' commands and executes a push or pull even if there are any conflicts.
- 'Open in browser' opens a selected organization in your default browser. This is a handy way to execute the 'force:org:open' command without touching the command-line.
- 'Refresh' performs the full refresh of the organizations' list, so it executes 'force:org:list' command.
- 'Toggle details pane' shows or hides the details pane in the lower part of the Organizations manager.
And there is one more option that is available in the context menu for Scratch Orgs, while not being available in the toolbar — 'Generate a password'. Just two clicks instead of typing in the 'user:password:generate' command!
The last part of the 'Organizations Manager' pad is the details pane. If enabled it will show you all details about a selected organization — the same as the 'force:org:display' command.
By the way, it is very convenient to copy the org's details from the details pane, compared to doing the same in the command line
Salesforce DX — Scratch Orgs Creation
One of the main benefits of Salesforce DX is an ability to create Scratch Orgs in less than a couple minutes — directly from the command line, or from your favorite IDE. So if you need to see how your latest changes in a code will work, or if you need to make declarative changes in an organization's configuration you might need to create a Scratch Org. As always there are two ways:
- Complex — from the command line using the 'force:org:create' command with all of its 9 arguments and a configuration file (if needed);
- Easy — from The Welkin Suite with a couple clicks.
We are always looking for easy ways to do some essential actions, so here we will open the 'Organizations Manager' pad, select an appropriate Dev Hub, and choose the 'Create scratch organization' option from its context menu or from the toolbar.
In the Scratch Org creation wizard you have 3 simple options to specify:
- Alias — a name of an organization that will be used in the Organizations Manager and in different CLI commands;
- Create scratch organization with no namespace — creates a scratch org with no namespace. This would be useful when using a scratch org to test installations of packages with namespaces;
- Set the created organization as the default — sets some created organization as the default one for the SFDX CLI and different actions in the IDE.
After these easy options, you will need to specify the Scratch Org configuration itself. In The Welkin Suite you have 4 different following ways to do this:
- Create by Edition — allows you to quickly select an edition of a Scratch Organization (Developer, Group, Professional, or Enterprise), while all other configuration options will be set to their default options;
- Configure manually — allows you to manually configure all parameters of your Scratch Organization;
- Select configuration file path — select a previously created scratch org definition file, which should be used for this org;
- Use from project — uses a default scratch org definition file from a given project in your solution.
While the 'Configure manually' option requires the most time, it provides you with great options to fine-tune your Scratch organization:
When you select the 'Configure manually' option and press the 'Next' button, you will see the second step of the creation wizard with different options grouped into 3 sections:
- Org definition section, that contains the general parameters that are required for the org creation. You need to fill in all the fields, in this section.
- Org preferences section that contains various preferences of the organization, like what functionality is available. We want to draw your attention that the checkboxes in this category have 3 states - enabled, disabled and default.
- Set add-on features section that allows you to select additional features to be enabled for the newly created organization.
When you are done with all settings and press the 'Next' button the IDE will first execute the 'force:org:create' command with all needed arguments and then it will execute the 'force:org:display' command to get and cache the organization details for the future usage.
Salesforce DX — Exporting and Importing Sample Data
You don't need records in Salesforce to develop great Applications. However, you might need some specific records in Salesforce to ensure that an application works correctly or, maybe, you have some unit tests with 'SeeAllData'. Previously, working on a limited set of sandboxes allowed us to create such sample data manually and maintain it as-we-go — while this was not the best option it worked and it was the easiest one. The great thing in Salesforce DX is that it forces developers to think about sample data carefully, create it adding as many details as needed without a risk to lose it on a sandbox refresh! Even more — such sample data can and should be pushed into your Git repositories together with project sources!
Specifically for this purposes, Salesforce provided us a couple commands in the 'force:data' namespace, but their arguments are so complex to remember and specify quickly. So we've built-in the two most common options into the context menu in the Solution Explorer:
- When you right-click on any SOQL file there is an option to 'Export Data as a SObject Tree': once you click on this, the IDE will execute the 'sfdx:data:export' command with the given query for your default Scratch organization, and it will save the result in the same folder where the query is located.
- As you might have guessed — in the context menu for any json file, there's an opposite command — 'Import SObject Tree Data' that imports the given json file to a default Scratch org. Please be aware, that this command is available for any json file in a project — we are not doing any additional checks to see if a selected file really contains the exported data.
Salesforce DX — Common features
Above we have highlighted the all-new features related to the SalesforceDX functionality, but what about those hundreds of small and big features that were available for you in The Welkin Suite before Blaze R6? Almost all of them are as well available for SFDX projects, but with one difference in behavior.
For regular Salesforce projects, the IDE stores the details that are required for the connection to a related organization in a project file itself — this is possible because each project is directly tied up with a corresponding organization. And there is always only one organization per one project. With Salesforce DX, the approach is finally changed from the 'organiation-centric' to the 'source-driven' one! What does this mean?
This means that your sources define your project, while Scratch Orgs are just a temporary way for you to test it. Taking this into account all pads that were tied up to projects (for example - Test Results, Logs, Code Coverage, etc.) won't have the details about the related Salesforce organization from the project itself. However, they will still keep working, but instead of using credentials from the project — the pads will show you the information and will provide you with the actions related to the default Scratch Org. This is the main difference in the behavior of the existing features in the IDE for Salesforce DX projects!
Some other differences are as noted below:
sObjects and Custom Settings definitions for the Apex Code Assistance functionality are retrieved for your default scratch organization. If you would switch your default scratch org, the IDE will retrieve the details for your new org in the background, and it will show you the corresponding completions after a small delay.
'Execute Anonymous Apex' and 'SOQL Executor' are also working with your default scratch organization.
The 'Pending Changes' panel is disabled for SFDX projects, since this information is handled by the SFDX CLI, and it is not available for TWS.
The regular 'Pull from Salesforce' option is not available for SFDX projects, because there is no direct project-organization connection - instead, you can pull sources from a specific organization using the 'Organizations Manager' pad.
SOQL Editor & Query Completion in Apex
As we have promised to our users — we were (and keep) working on the SOQL improvements. In the Blaze R6 version of The Welkin Suite, we are rolling out two updates related to the SOQL.
The first of them is the first iteration of a new SOQL completion in Apex. For now on, the IDE will suggest to you a list of possible fields and aggregate functions when you type in the SOQL query, which already has the 'FROM %OBJECT_NAME%' clause in it. Even in this way it is much faster to type in, for example, 'SELECT FROM Account', place the cursor between the 'SELECT' and 'FROM' keywords and hit Control+Space or just start typing to get the full list of possible fields and functions to use. We will continue our work on this functionality and will release updates in the next couple releases!
The second improvement is related to the SOQL Editor — you remember that you can build a query using just your mouse, selecting the needed fields. Previously the state of the checkboxes was not restored after re-opening a '.soql' file, however with the changes in Blaze R6 checkboxes will have the correct state after re-opening a file, so you will be able to modify your query in the same easy way - with just a couple clicks!
The Welkin Suite team also continues working on improving the existing functionality in the IDE and making it more stable, adding new abilities and solving issues. In the Blaze R6 version of TWS, we have solved some bugs and made additional changes to make your working process in The Welkin Suite more pleasant and comfortable. Let us know what we could make better even more and we will do everything possible - one step for this: email to firstname.lastname@example.org or post on TWS Forum.
Full list of changes
- Added Salesforce DX specific project types with corresponding new and updated functionality
- Added an 'Organizations Manager' panel for managing all SFDX-related organizations, including Dev Hubs and Scratch Orgs
- Added a Scratch org creation wizard
- Added an option to quickly export data from a scratch organization using any SOQL file for SFDX projects using a context menu option in the Solution Explorer
- Added an option to quickly import data to a scratch organization using any JSON file for SFDX projects using a context menu option in the Solution Explorer
- Added the SOQL queries completion in the Apex editor
- Removed a drop-down for displaying the code coverage by unit tests for test classes in the code editor
- Improved general stability of the IDE and its components
- Improved the SOQL Editor to restore the state of the checkboxes for the fields, included into the query, after re-opening a '.soql' file
- Fixed rare cases of TWS crash when closing a file after making changes in it
- Fixed rare cases of TWS crash when filtering files in the Static Resources Bundle or Lightning Bundle Explorer
Your comment may be the first