Salesforce has rolled out many interesting new features in Salesforce Summer’18 Release, especially for developers. JET BI has summarized the best features for you in this blog. Find out them and get to work.
1. Switch statement
The feature we’ve waited for so long got more than 17,000 points at Salesforce Community Ideas was added to Apex. This feature must simplify your code by replacing many if-else statements. Unlike many popular languages like Java, C# or ECMAScript the case keyword was replaced by when keyword. Here’s an example of its usage:
The when values can be single values, multiple values, or SObject types. For example:
The switch statement evaluates the expression and executes the code block for the matching when value. If no value matches, the code block for the when else block is executed. If there isn’t a when else block, no action is taken.
There is no fall-through. After the code block is executed for a particular when block, the switch statement exits.
2. SOQL COUNT() Function Limitation
The SOQL COUNT() function doesn’t count toward limits. Previously, each individual record matched by the SOQL COUNT() and COUNT(fieldName) functions counted toward the query row limit. So requesting a count could have a significant impact on governor limits, especially when working with many records. Now, if a query using one of these functions returns an integer, it only counts as one query row toward the governor limit. If a query using one of these functions returns an array of AggregateResult objects, only the total number of AggregateResult objects counts toward the limit.
3. @namespaceAccessible Annotation
Apex method accessibility within second-generation packaging (beta) has been changed. Now, Apex interfaces, classes, methods, and properties aren’t accessible to other packages that they share a namespace with unless explicitly annotated. The behavior of Apex that is marked global is unchanged. The modifier applies only to packages that have a namespace. The new @namespaceAccessible annotation marks public or protected Apex as available to other packages that share a namespace. If you use this annotation in Apex that isn’t packaged, it has no impact, so it can be deployed to development orgs. You can add or remove the @namespaceAccessible annotation at any time, even on managed and released Apex code. Make sure that you don’t have dependent packages relying on the functionality of the annotation before adding or removing it.
Lightning Component Framework
1. New Lightning Components
Streamlines creating a form to add, view, or update a record. This component makes it easier to create record forms than building them manually with lightning:recordEditForm and lightning:recordViewForm. Set the mode attribute to view, edit, or readonly to specify the type of form. This form was created by specifying mode=”edit” to add a record.
2. Changed Components
This component now supports mass inline editing, so you can edit content in multiple table cells and save the changes in one step. The component verifies that you want to update multiple items before it applies your changes. Columns now support horizontal alignment with the cellAttributes property. New attributes are described below:
|errors||Specifies an object containing information about cell-level, row-level, and table-level errors. Error messages are displayed in the table accordingly.|
|oncellchange||The action triggered when a cell’s value changes after an inline edit. Returns the draftValues object.|
|oncancel||The action triggered when clicking Cancel in the table footer during an inline edit.|
|onsave||The action triggered when clicking Save in the table footer during an inline edit. Returns the draftValues object.|
The following column property is new.
|editable||Specifies whether a column supports inline editing. The default is false|
The following values for the type column property are new.
|boolean||Displays a checkbox in the column of a Boolean data type.|
|date-local||Displays a date field only, not a date and time field.|
|alignment||Specifies where to align data horizontally in a column. Allowed values are center, right, or left.|
The next components have new methods.
|refreshTab()||Refreshes a workspace tab or a subtab specified by tabId. Keep in mind that the first subtab has the same tabId as the workspace tab.|
|disableTabClose()||Prevents a workspace tab or subtab from closing. This method removes the close button from a tab or subtab, and disables the keyboard shortcuts that close tabs and subtabs.|
3. New Lightning Interfaces
In Summer '18 Release, Salesforce has given us several new interfaces. Here they are:
|lightning:availableForFlowActions||Enables using a component’s client-side controller as an action in a flow.|
|lightning:isUrlAddressable||Enables navigating directly to a component from a URL.|
|lightning:hasPageReference||Enables a component to include a pageReference object as an attribute. This interface is used by lightning:isUrlAddressable.|
4. Component CSS Class Names Updated
CSS class names used by Lightning components have changed to match the Block-Element-Modifier (BEM) notation that Salesforce Lightning Design System (SLDS) now uses. This change could impact on custom components in your org.
This change affects custom Lightning components with component-specific CSS that implements any SLDS class that contains a double dash in its name. This change applies to Lightning Experience in all editions.
Class names with a double dash now use a single underscore in place of the double dash. The CSS class slds-p-around--small becomes slds-p-around_small, for example. If you have created custom CSS in your components that refer to reference an SLDS class that contains a double dash, update your selectors for using to use a single underscore.
Changes in Locker Service
The Locker Service architectural layer enhances security by isolating individual Lightning components in their own containers and enforcing good coding practices. Locker Service compatibility is improved in this release.
The eval() function is now available in Locker Service, even when Strict CSP is enabled. This addition improves support for third-party libraries that evaluate code dynamically. Limitation: In Locker Service, eval() always works in the global scope of the namespace. The eval() function can’t access the local variables within the scope in which it’s called.
2. Performance Optimizations
Code executing inside Locker Service now runs faster, thanks to a new system of static references that allow the browser’s just-in-time optimizer to accelerate execution.
3. Cleaner Debugging
Previously, the process of sandboxing code in Locker Service introduced various wrappers around the code. Those wrappers were visible and confusing to users during debugging. The updated engine no longer needs wrappers, and your code looks the same whether Locker Service is on or off.
Apply Lightning Experience Stylesheets to Visualforce Pages
Lightning Experience Stylesheets feature introduced in Winter ’18 is generally available in Summer ‘18. You can style your Visualforce pages with the look of Lightning Experience when viewed in Lightning Experience or the Salesforce app by adding lightningStylesheets="true" in the <apex:page> tag.
The Visualforce page <body> element now includes the CSS scoping class slds-vf-scope when lightningStylesheets="true"in the <apex:page> tag. The scoping class matches your content to the Lightning Experience UI. When the lightningStylesheetsattribute is set to true, it overrides the standardStylesheets attribute.
The lightningStylesheets attribute can incorporate your organization’s theme in your Visualforce pages. Now you can style your page with Salesforce’s built-in themes or custom themes you create yourself.
The latest Salesforce release makes the platform more connected, faster, and smarter. We hope you have found our blog helpful and exciting. If you want to know more about other new features, you can find out about it here. Or you can get in touch with JET BI experts. Just write or call us and get fulfilling answers to challenging questions.