Yep, #Winter19 is here and it brings a lot of new features with it. In this post, let’s discuss a few of the new and changed features in Apex & Visualforce.
#1 APEX Features – Salesforce has introduced a few new features and enhancement for Apex. I have highlighted few of them here:
1. Inherited Sharing – “With Sharing” and “Without Sharing” have got a new sibling 👨👨👧 😆
Now you can use “Inherited Sharing” in a class signature. This sharing keyword will give you the flexibility to run your apex code with both with or without sharing settings, depending on the context it is being called from. Below are few highlights of this keyword:
- If the class is the entry point of a transaction, it will run in with sharing mode.
- If the class is a Visualforce controller, it will in with sharing mode.
- If the class is being called from some other class which is having without sharing setting, it will run in without sharing mode.
2. Now make API Calls to your own org without Remote Site Setting Or Named Credential🤗
Now you can make an API call to your own org without creating remote site setting or named credential. You can use System.Url.getOrgDomainUrl() to access REST or SOAP APIs. This feature is useful:
- To access API only restricted object.
- Make API calls using system methods like System.Url.getOrgDomainUrl() and System.UserInfo.getSessionId()
Note: Please use new System.UserInfo.getSessionId() method to get user’s session id.
3. New Apex Methods
- Schema.DescribeFieldResult.isAiPredictionField() – Returns a Boolean indicating whether the field is enabled to display Einstein prediction data.
- Schema.DescribeSObjectResult.getRecordTypeInfosByDeveloperName() – Returns a map that matches developer names to their associated record type.
- Schema.RecordTypeInfo.getDeveloperName() – Returns the developer name for this record type.
- System.Test.stopTest() – Executes scheduled actions for record-change processes (built in Process Builder), and resumes flows that are waiting on alarms (time-based events).
- System.Url.getOrgDomainUrl() – Returns the canonical URL for your Org.
- System.UserInfo.getSessionId() – This method returns the session ID only when the code is run by an active, valid user
- runTests() (SOAP API Method) – This method will now include two more parameters in response:
- flowCoverage – An array of results from test runs that executed flows.
- flowCoverageWarnings – An array of warnings generated by test runs that executed flows.
#2 Visualforce Features – Not much here, but still few things to notice
1. URL Redirect Parameters Are No Longer Case-Sensitive
The protected URL parameters used in Visualforce pages—retURL, startURL, cancelURL, and saveURL—are no longer case-sensitive. If you change the parameter value from retURL to returl, the system now recognizes it as a protected parameter. Protected URL parameters allow redirects from Visualforce pages to salesforce.com or *.force.com domains and prevent malicious redirects to third-party domains.
2. Create and Edit Field Sets in Lightning Experience
Now you can create and edit fieldsets in Lightning Experience.
Winter 19 has a lot for Salesforce developers and makes it even easier to write code and implement features. The source of above post and content is official release notes.