Salesforce Code Builder – New Productivity Tools

Salesforce announced new tools for developers and admins that can help to innovate faster than ever by building scalable, modern apps through a combination of clicks and code without ever having to sacrifice user experience or crucial security measures. Code Builder Code Builder is a web-based development environment fully optimized for Salesforce development and powered by Microsoft’s Visual Studio Codespaces. Code Builder is a full-featured version of Visual Studio Code running completely in the browser and backed by a powerful cloud-hosted developer environment. In just one click, you have a full environment without any setup or configuration. Code Builder comes with everything you need to build applications on the Salesforce Platform: Including Salesforce Extensions The Salesforce CLI Git integration It’s authenticated to your current Salesforce org. Every instance of Code Builder is backed by its own powerful Virtual Machine. This means Code Builder will allow you to do everything from simple code edits to Lightning Web Component development and advanced Apex debugging. Salesforce Functions Salesforce Functions is a service that lets developers write code that integrates with their data and events on the Salesforce Platform, and run it on-demand with elastic scale in a serverless environment. It empowers development teams to focus on delivering apps and business logic fast, instead of managing infrastructure. To accelerate app building, developers have the flexibility to innovate using languages they already know. They can quickly build, test, and debug Functions locally using the Salesforce developer tools. Admins or other users can extend their business processes by calling Functions from existing Apex code or low-code tools like Flow or even distribute them as part of AppExchange packages. DevOps Center DevOps Center allow admins and other declarative developers build against source control, collaborate better with programmatic developers, release apps faster, and do so with modern workflows like continuous integration and delivery. DevOps Center allows organizations to continue to prioritize release velocity, simplifying how apps are progressed through development environments from concept to launch, and boosting both the speed and quality of deployments. And since DevOps Center allows you to develop in your traditional sandboxes, you can also take advantage of additional capabilities like Data Mask that anonymize sensitive data in your testing environments — delivering speed without sacrificing trust. Code Builder Features Lightning Web Components Developers can now write, debug, and deploy LWC directly from the browser. Code Builder provides modern development features like code completion, inline documentation, refactoring, linting, and much more. Apex With Code Builder you can do everything in the browser, including using the rich Apex debugging capabilities. Org metadata Code Builder provides access to the full metadata of an org. Using the Org Browser you can open any metadata type for inspection and editing. Once you make changes to your metadata, the change is saved instantly to your org. Application Lifecycle Management Code Builder allow you to connect or create multiple orgs This means that it isn’t limited to the simple editing of org metadata. You can use it to script deployments between multiple orgs and test changes in scratch orgs. SOQL queries SOQL Query Builder allow you to write and execute SOQL queries with an easy to use graphical interface while also allowing for editing the query syntax directly for more advanced features. A powerful developer environment Code Builder is a powerful cloud-hosted developer environment. You can access the command line to run tools like the Salesforce CLI and save files to the disk which are persisted for the next time you come back. Code Builder is in Pilot June 25, 2020 with a limited group of customers. If you’re interested in learning more, please reach out to your Account team at Salesforce. If you’re interested in our articles, follow us on the Linkedin page.
How to Build Custom Flexible Rest Architecture in the Salesforce

The Classic Salesforce platform is designed to use the MVC pattern for developing applications and customizing existing functionality. The benefits of server rendering are obvious, but we often need more dynamic in the application. In this case, Rest Services will help us. By default, Salesforce has the following capabilities: Rest API Soap API Remote Actions The platform is also known for its limits. In this case — API Usage Limit. We will get rid of the problems and overcome the limits. Solution The solution is to use the standard Visualforce page with a custom controller to get the result of the request. As a result, we have a page with the following contents: 📄 Copy to clipboard 1 2 3 4 5 6 <apex:page controller="GS_RestApiController" action="{!execute}" contenttype="text/javascript" showHeader="false" sidebar="false"> <apex:outputText value="{!response}" escape="false"/> </apex:page> The method execute from the GS_RestApiController controller will be executed when the page is loaded. The result will be bound into the outputText. Controller Code: 📄 Copy to clipboard 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 public class GS_RestApiController { private static final String COMMAND_NAME_PARAM = 'command'; private Map<String, String> commandAliasNameMap = new Map<String, String>{ 'test' => 'FirstTest' }; public String response {get; private set;} public GS_RestApiController() { } public void execute() { this.response = getCommand().execute().toJSON(); } private GS_CommandContainer.GS_Command getCommand() { Map<String, String> params = ApexPages.currentPage().getParameters(); String commandName = params.get(COMMAND_NAME_PARAM); if (commandAliasNameMap.containsKey(commandName)) { commandName = commandAliasNameMap.get(commandName); } params.remove(COMMAND_NAME_PARAM); return GS_CommandFactory.create(commandName, params); } } In the controller, we use the command param to execute the command, and we have the map between the command and its alias if necessary. All commands are stored in container class — GS_CommandContainer 📄 Copy to clipboard 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 public class GS_CommandContainer { public abstract class GS_Command { private Map<String, String> params = new Map<String, String>(); public void setParams(Map<String, String> params) { this.params = params; } public GS_RestResponse execute() { try { Object resultObject = perform(); return new GS_RestResponse(GS_StatusCode.OK, getMessage(), resultObject); } catch (GS_Exception exp) { String message = exp.getMessage() + exp.getStackTraceString(); return new GS_RestResponse(GS_StatusCode.ERROR, message); } catch (Exception exp) { String message = exp.getMessage() + exp.getStackTraceString(); return new GS_RestResponse(GS_StatusCode.ERROR, message); } } public abstract Object perform(); public virtual String getMessage() { return null; } } public class GS_DefaultCommand extends GS_Command { public override Object perform() { return 'This is defult result.'; } public override String getMessage() { return 'This is default message.'; } } Thus, to add a new command, it is necessary simply to extend the base class GS_Command and implement the perform() method where the execution logic will be present. GS_CommandFactory is designed to create an instance of the GS_Command class. 📄 Copy to clipboard 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 public class GS_CommandFactory { private static final String DOT = '.'; private static final String COMMAND_CONTAINER_NAME = 'GS_CommandContainer'; private static final String DEFAULT_COMMAND_NAME = 'GS_DefaultCommand'; private static final String COMMAND_NAME_TEMPLATE = 'GS_{0}Command'; private static final String COMMAND_NAME_TEMPLATE_WITH_CONTAINER = COMMAND_CONTAINER_NAME + DOT + COMMAND_NAME_TEMPLATE; private static final String DEFAULT_COMMAND_NAME_TEMPLATE_WITH_CONTAINER = COMMAND_CONTAINER_NAME + DOT + DEFAULT_COMMAND_NAME; public static GS_CommandContainer.GS_Command create() { Type commandType = Type.forName(DEFAULT_COMMAND_NAME_TEMPLATE_WITH_CONTAINER); GS_CommandContainer.GS_Command command = (GS_CommandContainer.GS_Command)commandType.newInstance(); return command; } public static GS_CommandContainer.GS_Command create(String commandName, Map<String, String> params) { if(String.isBlank(commandName)) { create(); } String commandClassName = String.format(COMMAND_NAME_TEMPLATE_WITH_CONTAINER, new String[] {commandName}); Type commandType = Type.forName(commandClassName); if(commandType == null) { commandType = Type.forName(DEFAULT_COMMAND_NAME_TEMPLATE_WITH_CONTAINER); } GS_CommandContainer.GS_Command command = (GS_CommandContainer.GS_Command)commandType.newInstance(); command.setParams(params); return command; } } It creates an instance of the required command, depending on the given parameter, or creates an instance of the default class if no such command is found. The example of use is quite simple: 📄 Copy to clipboard 1 var result = $.post('{!Page.RestApi}', {command : 'test'}); The result is: 📄 Copy to clipboard 1 {"result":"FirstTestResult + Params : {}","message":"FirstTestMessage","code":200} When you perform a request without any parameters, the default command is executed. The command name must match the COMMAND_NAME_TEMPLATE template described in GS_CommandFactory, and it is also possible to add the alias and command name to the commandAliasNameMap in the GS_RestApiController. From our side, the architecture is convenient and easily extensible. The source code you can find on GitHub. Nowadays, when Lightning Components is became standard for developing UI. It make less sense. But it can help you if you make custom UI with any JS framework (Angular, React, Vue) or you faced with any problem related with AuraEnabled methods.
How to fix ‘Error: Incorrect parameter type for function ‘ISPICKVAL()’’

You can face a strange issue if you create a formula field in Salesforce and try to use standard ISPICKVAL function with Custom Label because you don’t want to hardcode the values.
How to fix ‘Bad value for restricted picklist field’ error

Users or developers may receive the following error when they attempt to create or update a record in Salesforce: Error: Invalid Data. Review all error messages below to correct your data.‘Bad value for restricted picklist field: PicklistValue’ This error occurs when the picklist field referenced in the error message meets each of the following conditions:
Free Salesforce Certification

We all know how important it is to improve your skills. If now you have more free time – it becomes more relevant. Salesforce really knows how to train and offers us some free ways to grow. We gathered them together, it remains only to use what suits you!
How to merge Accounts in Salesforce

Data quality is one of the most important things you have to watch to get the most out of Salesforce. This helps your sales team to obtain accurate customer data in accordance with various privacy and privacy rules. Salesforce gives you tools for managing duplicates one at a time and across your org, and to track your progress in eliminating duplicates. We will show how to merge Accounts in different interfaces and do not forget about a little Salesforce Hack at the end of the article.
How To Deploy The Project To Salesforce

Problem: We in TrueSolv do not like Apache Ant because we need to configure it using xml. It looks out of date. The question is how to deploy the Salesforce project without Apache Ant? Solution: We can use Metadata API with sfdx.
Working with cookies from Lightning

I want to share with you several ready to use JS functions to working with cookies from Lightning, both Aura Component and Web Components. createCookie function gives an ability to create a cookie with a particular name, value, and time to live.
How To Share Code Between Aura And LWC

Now you can build Lightning components using two programming models: Lightning Web Components, and the original model, Aura Components. Most of the projects consist of Aura Components but more and more developers trying to use LWC for new components. Developers faced with the issue to use common functions in Aura and Lightning Web Components. The solution is pretty simple: