New analysis in Salesforce Optimizer Reports

New analysis in Salesforce Optimizer Reports – Summer’17 release

What is Salesforce Optimizer? Optimizer evaluates your implementation to determine how your company uses certain Salesforce features, then identifies ways that you can improve your implementation for your company.

Optimizer provides analysis report on Storage, Fields, custom code, Custom Layouts for objects, Reports and dashboards, validation rules, sharing rules, workflow rules, User Management and profiles and permission sets.

Below are the additional items added to Salesforce optimizer reporting with summer’17 release.

   – File storage limits

   – Data storage limits

  – New Apex and visualforce code that’s running out-of-date API versions

   – Page Layouts that are not assigned to record types and record types that are not added to profiles

   – Roles that are not assigned to roles.

   – User who access Salesforce on unsupported browsers

   – Checks for reports and dashboards that have not been run more than a year.

Hide Option to Switch to Salesforce classic

Hide Option to Switch to Salesforce classic – Summer’17 feature

Hide Option to Switch to Salesforce classic, Salesforce has provided this feature in Summer’17 to hide Switch to Salesforce classic option in setup menu.

To enable this, go to profiles and permission sets and enable “Hide Option to Switch to Salesforce classic” permission. We can enable this if we are ready to enable lighting version without looking back to salesforce classic version.

Generally, when we enable lightning version, users will get switcher option to switch between two user interfaces (Salesforce classic and lightning). If you want some users or all users stick to lightning version, you can use this feature to remove switcher.

Below are considerations we must keep in mind when we enable this feature.

If users access features that aren’t available in Lightning Experience, they temporarily access Salesforce Classic in a new browser tab, even though the permission is enabled. They use Salesforce Classic only as long as they’re using a feature that’s not available in Lightning Experience.

The permission doesn’t affect the full site link in the Salesforce1 mobile browser app. Salesforce1 users always switch to the Salesforce Classic version of the full site, regardless of the interface they see from desktop devices.

Refer salesforce summer’17 release notes for more details.

https://releasenotes.docs.salesforce.com/en-us/summer17/release-notes/rn_general_lex_hide_switcher.htm

Filed history related lists in Lightning experience

Filed history related lists in Lightning experience – Available with Summer 17 release

Filed history related lists in Lightning experience, With Summer’17 release Field history related lists in lightning experience are available. This was not available in lightning experience before summer’17 release.

If Field history related lists are already added in salesforce classic version, those are available in lighting version as well with salesforce summer’17 release. If field history related list is not added, you can add this related list to your layout in lighting version.

If you want to enable field history tracking on lightning version, go to object manager, select an object, click on fields and relationships, click field history tracking and select the fields to track and finally add object history related list to page layout.

For more details on this refer salesforce summer’17 release notes.

VisualforceAccessMetrics object – Summer’17

VisualforceAccessMetrics object – Access visualforce metrics using SOAP API

VisualforceAccessMetrics object, Salesforce providing this object to query metrics on the visualforce pages. We can use this object in salesforce SOAP API.

Example Query:

SELECT ApexPageId,DailyPageViewCount,Id,MetricsDate FROM VisualforceAccessMetrics

About fields of this object:

DailyPageViewCount field: This field is type of integer and it stores daily page view count.

MetricsDate: This field is type of date and the date the metrics were collected.

ApexPageId: ID of the tracked visualforce page.

This object supports count(), query() and retrieve() calls.

Using this we can track,

– Number of views each Visualforce page in your org receives in a 24-hour
time period.

– To find out how many views a page got over the course of multiple days, we can query multiple VisualforceAccessMetrics objects for the same ApexPageId.

WITH SPELL_CORRECTION and WITH HIGHLIGHT

WITH SPELL_CORRECTION and WITH HIGHLIGHT – SOSL clauses in Summer’17

WITH SPELL_CORRECTION and WITH HIGHLIGHT clauses in Summer’17 for SOSL (Salesforce Object Search Language): Below are the two more SOSL clauses available in salesforce with Summer’17 release (API version 40).

1. WITH HIGHLIGHT

2. WITH SPELL_CORRECTION

WITH HIGHLIGHT:

This is an optional clause that can be added to a SOSL query for business account, campaign, contact, lead, opportunity, quote, user and custom object searches. It highlights the terms matching the search query in search results, making it easier to identity relevant content.

This clause was available for business account, campaign, contact, lead, opportunity, quote, user object with version 39 or later. It is also available for Custom object and fields with version 40 or later.

Highlighted search terms are generated only from the following standard and custom field types:

Auto number, Email, Text, Text Area and Text Area (Long).

Example:

FIND {stutorials} IN ALL FIELDS RETURNING Account(Name,Description) WITH HIGHLIGHT

Above SOSL statement returns search results with search item stutorials highlighted.

Important notes about WITH HIGHLIGHT clause:

– Only 25 records per entity per SOSL query are highlighted.

– Search teams that contains a wildcard are not highlighted.

– Other objects that are included in searches that contain WITH HIGHLIGHT don’t return highlighted search terms.

– This clause in SOSL is supported in SOAP API and REST API.

WITH SPELL_CORRECTION:

– This is an optional clause that can be added to a SOSL query.

– When it set to true, spell correction is enabled for searches that support spell correction. When it set to false, spell correction is not enabled. Default value is true.

– This clause is available with version 40 or later versions.

Example:

FIND {your search string} IN ALL FIELDS RETURNING Account WITH SPELL_CORRECTION = false

– This clause in SOSL is supported in SOAP API, REST API and Apex.

New and changed standard objects in Salesforce summer’17

New and changed standard objects in Salesforce summer’17

With Salesforce summer’17 release we can access more data objects in salesforce. Below is the list of new and changed objects available with Salesforce Summer’17 release.

New Objects:

CampaignHistory, ContentBody, ContentWorkspaceMember, ContentWorkspacePermission, ForecastingDisplayedFamily, VisualforceAccessMetrics, MaintenanceAsset, MaintenancePlan, ProductRequest, ProductRequestLineItem, ProductRequestFeed, ProductRequestHistory, ProductRequestOwnerSharingRule, ProductRequestShare, ProductTransfer, ProductTransferFeed, ProductTransferHistory, ProductTransferOwnerSharingRule, ProductTransferShare, Shipment, VoiceMailMessage, VoiceMailMessageShare.

Changed Objects:

BusinessHours, ContentDistribution, ContentNote, ContentVersion, ContentWorkspace, EmailTemplate, EventLogFile, LoginEvent, NetworkActivityAudit, Quote, QuoteLineItem, SlaProcess, WorkOrder.

To know more about these changes, you can refer Salesforce summer’17 release notes.

https://releasenotes.docs.salesforce.com/en-us/summer17/release-notes/rn_api_objects.htm

How to access metadata from APEX?

How to access metadata from APEX? – Summer’17 release feature

Access Metadata from Apex, What is metadata in salesforce? In Salesforce, if you create object, field, class, page, trigger and any other component type which represents org configuration and customization will be stored in the form of metadata. We can access this metadata by using Metadata API. With Summer’17 Salesforce release, we can use classes in the metadata name space to access metadata components from Apex Code.

As per the salesforce release notes documentation, Access metadata from your Apex code to handle below tasks.

Customizing app installs or upgrades: During or after an install (or upgrade), your app can create or update metadata to let users configure your app.

Customizing apps after installation: After your app is installed, you can use metadata in Apex to let admins configure your app using the UI that your app provides rather than having admins manually use the standard Salesforce setup UI.

Securely accessing protected metadata: Update metadata that your app uses internally without exposing these types and components to your users.

Creating custom configuration tools: Use metadata in Apex to provide custom tools for admins to customize apps and packages.

This feature (Metadata access in apex) is currently limited to custom metadata records and page layouts. We can retrieve, create or update custom metadata but we cannot delete metadata through Apex.

– Use Metadata.Operations class to retrieve and deploy metadata.

– Use the Metadata.Operations.retrieve() method to synchronously retrieve metadata from the current org.

-Use the Metadata.Operations.enqueueDeployment() method to asynchronously deploy metadata to the current org.

Refer Salesforce Apex developer guide to know how to use this feature.

System assertEquals Salesforce – System methods

System assertEquals Salesforce

System assertEquals Salesforce

System assertEquals Salesforce, Here I am posting about assert methods in System class. This helps everyone to find the differences between assert methods in salesforce.

Below are the three assert methods in system class.
1. System.assert(condition, msg)
2. System.assertEquals(expected, actual, msg)
3. System.assertNotEquals(expected, actual, msg)

What is System.assert(condition, msg)?

This method asserts that the specified condition is true. If it is not true, a fatal error is returned that causes code execution to halt.

Signature of this method:
Public static void assert(Boolean condition, Object msg)

This method is having two parameters, one is condition which is Boolean type, the other one is msg which is optional and object type.

 What is system.assertEquals(expected, actual, msg)?

This asserts that the first two arguments are the same. if they are not same, a fatal error is returned that causes code execution halt.

Signature of this method:
Public static void assertEquals(Object expected, Objecet actual, object msg)

This method is having three parameters, one is expected which is a type of object, second one is actual which is also type of object and the other one msg which is optional and type of object.

What is system.assertNotEquals(expected, actual, msg)?

This asserts that the first two arguments are not same. if they are the same, a fatal error is returned that causes code execution halt.

Signature of this method:
Public static void assertNotEquals(Object expected, Objecet actual, object msg)

This method is having three parameters, one is expected which is a type of object, second one is actual which is also type of object and the other one msg which is optional and type of object.

Note: We cannot catch an assertion failure using a try/catch block even though it is logged as an exception in case all above three methods.

To know more about this refer below Salesforce documentation URL about salesforce system class.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_system.htm#apex_System_System_methods

Salesforce integration testing – WebServiceMock interface

Salesforce integration testing – WebServiceMock interface

Salesforce integration testing: Generating web service class and how to use those web service classes was explained in my previous post. Here I am going to explain about how to write test class for web services class generated WSDL2Apex.

Every Salesforce developer know about importance of test classes. At least 75% code coverage is required to deploy code to production. Test coverage includes classes generated by WSDL2Apex.

As a Salesforce developer, to write test classes for web service you should spend some time as test methods do not support web service callouts. Apex provides inbuild interface “WebServiceMock” and the “Test.setMock” method. Developers can use this interface to receive fake response in a test method.

What is WebServiceMock interface?

WebServiceMock interface enables sending fake response when testing web service callouts of a class auto-generated from WSDL.

doInvoke is the method of this interface.

doInvoke(stub, soapRequest, responseMap, endpoint, soapAction, requestName, responseNameSpace, responseName, responseType)

The implementation of this method is called by the Apex Runtime to send a fake response when a service callout is made after Test.setMock has been called.

You can refer below Salesforce documentation to know more about this interface.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_interface_webservicemock.htm

SOAP web service – Creating a class from WSDL

SOAP web service – How to creating a class from WSDL document?

SOAP web service class can be generated automatically by using WSDL document. Generating WSDL document allows Salesforce developers to make callouts to the external web service in their Apex code.

Follow below steps to generate apex class from a WSDL:

1.Go to Apex Classes form setup menu.
2.Click “Generate from WSDL” button.

SOAP Web Service 1
3.Select WSDL document(XML file) you are using to generate apex class by clikcing choose file lookup button. This WSDL document is base to generate apex class.

SOAP Web Service 2Here I selected Test-SOAP webservice WSDL file which is rounded by red color line in the above image. You can select WSDL by clicking on choose File button.

4.Click Parse WSDL button which is highleted in the above image to verify WSDL document contents. It generates default class name based on WSDL document. It report errors in case of the WSDL contains schema types or constructs that aren’t supported by Apex classes, or if the resulting classes exceed the 1-million-character limit on Apex classes. For example, the Salesforce SOAP API.

SOAP Web Service 3You can rename the class. And click on Generate Apex button. The final page of the wizard shows which classes were successfully generated, along with any errors from other classes. The page also provides a link to view successfully generated code.

Generated Apex classes include stub and type classes for calling the third-party Web service represented by the WSDL document. These classes allow you to call the external Web service from Apex.

When you generate Apex classes by using WSDL, it generated 2 classes, one is with given name for synchronus callouts and other is prefixed with Async for asynchronus callouts.

SOAP Web Service 4

Refere here to know more about SOAP callouts: https://trailhead.salesforce.com/modules/apex_integration_services/units/apex_integration_soap_callouts