Wednesday, June 15, 2022

How to Make Lightning Experience the Only Experience for Some Users

 Ready for some of your users to go all-in on Lightning Experience? Keep them in the new interface by removing the option to switch back to Salesforce Classic.

When you enable Lightning Experience, users with the Lightning Experience User permission automatically get the Switcher. The Switcher lets users move back and forth between the new and classic Salesforce interfaces. But you can remove the Switcher for designated users.

From Setup, create a permission set that includes the Hide Option to Switch to Salesforce Classic permission then assign the permission set to the desired users. Or, enable the permission in a custom profile to remove the Switcher from everyone in that profile.

Hide Option to Switch to Salesforce Classic permission in profiles and permission sets

Users see Lightning Experience the next time they log in to Salesforce. They no longer see the Switch to Salesforce Classic link.

Even if the Hide Option to Switch to Salesforce Classic permission set is assigned, admins with the Customize Application or Modify All Data user permission can use the Switcher to get to Salesforce Classic.

How to Turn Off Salesforce Classic for Your Org

 Hi all today we are going to disscuss , how to Turn Off Salesforce Classic for Your Org.When all your users are working in Lightning Experience and everyone has the features we need to stop supporting two interfaces—by turning off your org’s access to Salesforce Classic


Turn off your org’s access to Salesforce Classic by removing the Switcher for all users.

  1. From Setup in Lightning Experience, enter Lightning in the Quick Find box, then select Lightning Experience Transition Assistant.
  2. Select the Optimize phase.
  3. Click Turn Off Salesforce Classic for Your Org to expand the stage.
  4. Turn on Make Lightning Experience your org’s only experience.

Users see Lightning Experience the next time they log in to Salesforce. They no longer see the Switch to Salesforce Classic link.

Important
IMPORTANT Restoring Salesforce Classic access for specific users after removing the Switcher from your org isn’t possible. If you want to turn off Salesforce Classic access for most but not all users, use the Hide Option to Switch to Salesforce Classic permission instead.

Thursday, June 2, 2022

How to Fire Platform Events from Batch Apex

Today we will discuss about, How to Fire Platform Events from Batch Apex

Batch class needs to implement "Database.RaisesPlatformEvents" interface in order to fire platform event.

global class SK_AccountProcessBatch implements Database.Batchable<sObject>,Database.RaisesPlatformEvents{

   //batch logic

}

below is the sample code for the same:-

global with sharing class PlatformEventRaise implements Database.Batchable<SObject>, Database.RaisesPlatformEvents{

    // class implementation

    global Database.QueryLocator start(Database.BatchableContext BC){

        return Database.getQueryLocator('Select Id ,Name,Rating,Industry, BillingAddress,BillingStreet,BillingCity, BillingCountry, BillingPostalCode,BillingState,Phone from Account  where BillingStreet!=NULL');

    }

    global void execute(Database.BatchableContext BC, List<sObject> scope){

         List<Account> accs =(List<Account>) scope ; 

        List<Cloud_News__e> cnewList = new List<Cloud_News__e>();

        for(Account a : accs){

            // Create an instance of the event and store it in the newsEvent variable

            Cloud_News__e newsEvent = new Cloud_News__e(

                Location__c=a.BillingStreet, 

                Urgent__c=true, 

                News_Content__c=a.BillingStreet);

              cnewList.add(newsEvent) ;

         }      

// Call method to publish events

        Database.SaveResult sr =  EventBus.publish(cnewList);

        // Inspect publishing result 

        if (sr.isSuccess()) {

            System.debug('Successfully published event.');

        } else {

            for(Database.Error err : sr.getErrors()) {

                System.debug('Error returned: ' +  err.getStatusCode() +' - ' + err.getMessage());

            }

        }       

    }    

    global void finish(Database.BatchableContext BC){

    }

}