#Salesforce #Release #Summer20 #Lightning #Developers #BeReleaseReady

1. Communicate Across Salesforce UI Technologies with Lightning Message Service (Generally Available)

Where: This feature is available in Lightning Experience. To create a Lightning message channel, use Enterprise, Performance, Unlimited, and Developer editions.

How: Components and pages communicate over Lightning message channels. In this example, a Visualforce page subscribes to a message channel on which a Lightning web component publishes.

// publisherComponent.js
import { LightningElement, wire } from 'lwc';
import { publish, MessageContext } from 'lightning/messageService';
import SAMPLEMC from "@salesforce/messageChannel/SampleMessageChannel__c";
export default class PublisherComponent extends LightningElement {
@wire(MessageContext)
messageContext;
handleClick() {
const message = {
recordId: "001xx000003NGSFAA4",
recordData: {
value: "Burlington Textiles Corp of America"
}
};
publish(this.messageContext, SAMPLEMC, message);
}
}

The Visualforce page subscribes to the same message channel.

<apex:page>
<div>
<p>Subscribe to SampleMessageChannel</p>
<button onclick="subscribeMC()">Subscribe</button>
<p>Unsubscribe from SampleMessageChannel</p>
<button onclick="unsubscribeMC()">Unsubscribe</button>
<br/>
<br/>
<p>Received message:</p>
<textarea id="MCMessageTextArea" rows="10" style="disabled:true;resize:none;width:100%;"/>
</div>
<script>
// Load the MessageChannel token in a variable
var SAMPLEMC = "{!$MessageChannel.SampleMessageChannel__c}";
var subscriptionToMC;
// Display message in the textarea field
function onMCPublished(message) {
var textArea = document.querySelector("#MCMessageTextArea");
textArea.innerHTML = message ? JSON.stringify(message, null, '\t') : 'no message payload';
}
function subscribeMC() {
if (!subscriptionToMC) {
subscriptionToMC = sforce.one.subscribe(SAMPLEMC, onMCPublished});
}
}
function unsubscribeMC() {
if (subscriptionToMC) {
sforce.one.unsubscribe(subscriptionToMC);
subscriptionToMC = null;
}
}
</script>
</apex:page>

If you worked with Lightning message service in beta, note the following change for the GA release. In the beta release, the subscribe() method included a scope parameter, with a single default value of APPLICATION. Scope defines where subscribing components receive messages in your application. The Lightning message service now lets you limit scope to the active tab only (default) or include the entire application.

To specify active scope, you don’t need to include the scope parameter, since it’s the default behavior. To specify scope for the entire application, continue to use the scope parameter with a value of APPLICATION. When using the active scope, a message channel is limited to communication between components in an active navigation tab, an active navigation item, or a utility item. Utility items are always active. A navigation tab or item is active when it’s selected.

2. Get Information About the Current Lightning Community

Where: This change applies to Lightning web components in Lightning communities in Enterprise, Performance, Unlimited, and Developer editions.

How: Use @salesforce/community/Id to import the ID of the current community — for example, when your component must pass the community ID as a parameter to an API.

import communityId from '@salesforce/community/Id';

Use @salesforce/community/basePath to import the base URL of your community and then dynamically construct the full URL — for example, when building a link component that works across several communities.

import communityBasePath from '@salesforce/community/basePath';

The base URL is the section of the community’s URL that comes after the domain. So if your community domain name is UniversalTelco.force.com and myPartnerCommunity was the URL value added when you created the community, the community’s URL is UniversalTelco.force.com/myPartnerCommunity/s. In this case, myPartnerCommunity/s is the base URL.

You can use @salesforce/community when targeting a Lightning community page only. If a component imports @salesforce/community, it can’t be used in any other Salesforce experience.

3. Develop Flow Screen Components That Work for Multiple Objects (Beta)

Where: This change applies to Lightning web components in Lightning Experience.

As a beta feature, the support of the generic sObject data type in custom flow screen components is a preview and isn’t part of the “Services” under your master subscription agreement with Salesforce. Use this feature at your sole discretion, and make your purchase decisions only on the basis of generally available products and features. Salesforce doesn’t guarantee general availability of this feature within any particular time frame or at all, and we can discontinue it at any time. This feature is for evaluation purposes only, not for production use. It’s offered as is and isn’t supported, and Salesforce has no liability for any harm or damage arising out of or in connection with it. All restrictions, Salesforce reservation of rights, obligations concerning the Services, and terms for related Non-Salesforce Applications and Content apply equally to your use of this feature. You can provide feedback and suggestions for the support of the generic sObject data type in custom flow screen components in the Trailblazer Community.

4. Control How to Serialize and Deserialize Apex Types

Where: This change applies to Lightning Experience and Salesforce Classic in Enterprise, Performance, Unlimited, and Developer editions.

How: The serializable and deserializable parameters of the @JsonAccess annotation enforce the contexts in which Apex allows serialization and deserialization. You can specify one or both parameters, but you can’t specify the annotation with no parameters. The valid values for the parameters to indicate whether serialization and deserialization are allowed:

  • never: never allowed
  • sameNamespace: allowed only for Apex code in the same namespace
  • samePackage: allowed only for Apex code in the same package (impacts only second-generation packages)
  • always: always allowed for any Apex code

In versions 48.0 and earlier, the default access for deserialization is always and the default access for serialization is sameNamespace to preserve the existing behavior. From version 49.0 onwards, the default access for both serialization and deserialization is sameNamespace.

This example code shows an Apex class marked with the @JsonAccess annotation.

@JsonAccess(serializable='never' deserializable='sameNamespace')
public class Foo {}

5. Enrich Change Event Messages with Extra Fields (Beta)

Where: This change applies to Lightning Experience and Salesforce Classic in Enterprise, Performance, Unlimited, and Developer editions.

As a beta feature, Change Data Capture Enrichment is a preview and isn’t part of the “Services” under your master subscription agreement with Salesforce. Use this feature at your sole discretion, and make your purchase decisions only on the basis of generally available products and features. Salesforce doesn’t guarantee general availability of this feature within any particular time frame or at all, and we can discontinue it at any time. This feature is for evaluation purposes only, not for production use. It’s offered as is and isn’t supported, and Salesforce has no liability for any harm or damage arising out of or in connection with it. All restrictions, Salesforce reservation of rights, obligations concerning the Services, and terms for related Non-Salesforce Applications and Content apply equally to your use of this feature. You can provide feedback and suggestions for Change Data Capture Enrichment in the Trailblazer Community. For information on enabling this feature in your org, contact Salesforce.

How: You define enrichment fields on a channel and a member of that channel. The channel can be either a custom channel or the ChangeEvents channel. Enriched change events are delivered only on the channel that is configured for enrichment. To add enrichment fields to a channel member and channel, use the PlatformEventChannelMember object in Tooling API or Metadata API.

This example uses Tooling API to enrich the AccountChangeEvent member on the SalesEvents__chn custom channel. The change event is enriched with two fields: a custom field (External_Account_ID__c) and a standard field (Industry). The associated POST request URI is: /services/data/v49.0/tooling/sobjects/PlatformEventChannelMember

Request Body:

{
"FullName": "SalesEvents_AccountChangeEvent",
"Metadata": {
"enrichedFields": [
{
"name": "External_Account_ID__c"
},
{
"name": "Industry"
}
],
"eventChannel": "SalesEvents__chn",
"selectedEntity": "AccountChangeEvent"
}
}

6. Lightning Web Components in Custom Tabs Are Reactive

Where: This change applies to Lightning web components in Lightning Experience and all versions of the Salesforce app.

Why: Lightning web components are designed to reactively track updates to query parameters, but were not reactive when used in custom tabs. Now, when components are used in custom tabs, they are aligned with the reactive design of other Lightning web components.

How: When using lightning/navigation to update the pageReference.state query parameters on the current page, you must track the query parameters. Track query parameters by declaring the currentPageReference variable in your component before getting a reference to the current page with @wire(CurrentPageReference). If you don’t declare the currentPageReference variable, query parameters aren’t tracked, so they aren’t updated and maintain their present value.

To update your code, add the currentPageReference variable to your component’s class.

export default class PageStateChangeExample extends NavigationMixin(LightningElement) {
// Declare the currentPageReference variable in order to track it
currentPageReference;
@wire(CurrentPageReference)
setCurrentPageReference(currentPageReference) {
this.currentPageReference = currentPageReference;

7. Restrict Access to @AuraEnabled Apex Methods for Authenticated Users Based on User Profile (Security Alert)

Where: This change applies to Aura and Lightning web components in Lightning Experience, Salesforce Classic, Lightning communities, and all versions of the Salesforce app.

Why: When the associated update is activated, an authenticated user can access an @AuraEnabled Apex method only when the user’s profile allows access to the Apex class. This update enforces user profile restrictions for Apex classes used by Aura and Lightning web components.

How: To view the security alert and see recommendations for your org, enter Security Alerts in the Quick Find box in Setup and select Security Alerts.

8. New and Changed Lightning Web Components

Changed Lightning Web Components

lightning-badgeThe following attributes are now supported.

  • icon-alternative-text — The alternative text used to describe the icon, which is displayed as tooltip text.
  • icon-name — The Lightning Design System name of the icon to display inside the badge. Specify the name in the format utility:down where utility is the category, and down is the specific icon to be displayed.
  • icon-position — The position for the icon inside the badge. Specify the value start to display the icon before the text or end to display it after the text. The default is start.

lightning-breadcrumbThe following methods are now supported.

  • blur() — Removes focus on the link.
  • focus() — Sets focus on the link.

lightning-datatableFor columns with text data type, the behavior of Clip text and Wrap text actions have changed. Clip text now shows only the truncated text of the first line. Previously, when content contained newline characters, the table displayed truncated text for each new line. The Wrap text action no longer preserves extra whitespace in the content, and breaks lines and hyphenates words as needed to fit the column.The following attribute is new.

  • column-widths-mode — Specifies how column widths are calculated. Set to fixed for columns with equal widths. Set to auto for column widths based on the width of the column content and the table width. The default is fixed.

The following property for the columns attribute is new.

  • hideDefaultActions — Specifies whether the default header actions are available on a column. The default is false.

lightning-inputThe input type color has changed.

  • The commit event is supported.

The input type number has changed.

  • Shortcuts k, K, m, and M are allowed. For example, in the en-US locale, when you enter 1k the field displays 1,000. Entering 1m results in 1,000,000. When the input field is focused, it displays the multiplied number. For example, entering 1k results in 1,000 on blur, and 1000 when the input is focused again. You can’t use these shortcuts when programmatically assigning input values to the value attribute.

The input types date and datetime have changed.

  • On the current month view of the date picker, you can now select a date from the previous and next month. Previously, dates from the previous and next month were disabled on the current month view unless you navigated directly to those months.
  • The names for months and weekdays in the date picker now use your Salesforce language setting. Previously, these names used your locale setting.

lightning-input-field Lookup fields are now supported in the Salesforce mobile app. When using the mobile app, users can do a lookup search for a supported object. The mobile lookup doesn’t support creating a new record from the lookup field’s dropdown menu.Name fields now support the Middle Name and Suffix fields on contact, lead, and user records. To display the complete name compound field, specify field-name=”Name”. Alternatively, display the fields individually by using a separate lightning-input-field component for each field. Pass in FirstName, MiddleName, or LastName to the field-name attribute for each component.

To enable the Middle Name and Suffix fields, from Setup enter User Interface in the Quick Find box, then select User Interface. In Lightning Experience, the User Interface page is the last item under the User Interface node. On the User Interface page, select Enable Middle Names for Person Names and Enable Name Suffixes for Person Names.

The field data types date and DateTime have changed.

  • On the current month view of the date picker, you can now select a date from the previous and next month. Previously, dates from the previous and next month were disabled on the current month view unless you navigated directly to those months.
  • The names for months and weekdays in the date picker now use your Salesforce language setting. Previously, these names used your locale setting.

The name field type has changed.

  • The suffix constituent field is now supported. To enable this field, from Setup enter User Interface in the Quick Find box, then select User Interface. In Lightning Experience, the User Interface page is the last item under the User Interface node. On the User Interface page, select Enable Name Suffixes for Person Names.

lightning-map The following attribute has changed.

  • map-markers — HTML tags you include in the title and description properties are not supported for security reasons. The tags are displayed as unescaped markup in the location list and the info window.

lightning-tabset The following method is new.

  • focus — Apply focus on the tab that’s currently selected.

lightning-tree-gridThe following types are now supported for the first data column in the table.

  • button — Displays a button using lightning-button.
  • button-icon — Displays a button icon using lightning-button-icon.

9. Check User Permissions for Lightning Web Components

Where: This change applies to Lightning web components in Lightning Experience and all versions of the Salesforce app.

Why: Permissions are a standard way to control access and behavior in a Salesforce org. Develop Lightning web components to behave a certain way based on the current user’s permissions.

How: To check whether a user has a permission, import a static reference to the permission and evaluate whether it’s true or false.

import hasPermission from '@salesforce/userPermission/PermissionName';

Custom permissions can include a namespace. Orgs use namespaces as unique identifiers for their own customization and packages. If the custom permission has a namespace, you must prepend the namespace followed by __ to the permission name.

import hasPermission from '@salesforce/customPermission/PermissionName';
import hasPermission from '@salesforce/customPermission/namespace__PermissionName';

The name of the static reference is your choice. We chose the format hasPermission to indicate that the reference contains a boolean.

This sample checks whether the current user has the ViewSetup standard permission.

// app.js
import { LightningElement } from 'lwc';
import hasViewSetup from '@salesforce/userPermission/ViewSetup';
export default class App extends LightingElement {
get isSetupEnabled() {
return hasViewSetup;
}
openSetup(e) {...}
}

If the user has the permission, the component enables a button.

<!-- app.html --><template>
<setup-panel-group>
<setup-button disabled={isSetupEnabled} onclick={openSetup}></setup-button>
</setup-panel-group>
</template>

This sample checks whether the current user has the ViewReport custom permission installed from a managed package with the acme namespace.

// app.js
import { LightningElement } from 'lwc';
import hasViewReport from '@salesforce/customPermission/acme__ViewReport';
export default class App extends LightingElement {
get isReportVisible() {
return hasViewReport;
}
}

If the user has the permission, the component displays the expense-report component .

<!-- app.html --><template>
<common-view></common-view>
<template if:true={isReportVisible}>
<c-expense-report></c-expense-report>
</template>
</template>

10. Create Relationships to Entity Particles from Custom Metadata Types

Where: This change applies to Lightning Experience and Salesforce Classic in Professional, Enterprise, Performance, Unlimited, Developer, and Database.com editions. Professional Edition orgs can create, edit, and delete custom metadata records only from types in installed packages.

How: To create a custom metadata relationship to an entity particle, first create an entity definition relationship field, then create an entity particle relationship field.

Now when you create a record for the custom metadata type, you can drill down and select a compound element for the relationship. For example, you can select Zip/Postal Code or Time Zone, which are compound elements of Address.

There are lot many other features as well, Official release notes are available HTML format as well as PDF file.

Say Hello To Me On Twitter | Facebook | Linkedin | MyBlog | Blogger | MyWebsite

#HappyLearning #Platform #SalesforceDeveloper #BeReleaseReady #Salesforceguy

--

--

Salesforce Evangelist || Blockchain Enthusiast || Architect || Trainer || Blogger || Believes in turning Ideas to reality || Day Dreamer || Happy Person

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Swayam Chouksey

Salesforce Evangelist || Blockchain Enthusiast || Architect || Trainer || Blogger || Believes in turning Ideas to reality || Day Dreamer || Happy Person