Monday, November 29, 2021

What is Database.setSavepoint in Salesforce?

 Database.setSavepoint() is used to define a point at which DML operations can be rolled back. If any error occurs during DML Operations, that contains many statements, the application will be rolled back to the most recent save point and the entire transaction will not be aborted.


All requests are delimited by the trigger, class method, Web Service, Visualforce page or anonymous block that executes the Apex code. If the entire request completes successfully, all changes are committed to the database. For example, suppose a Visualforce page called an Apex controller, which in turn called an additional Apex class. Only when all the Apex code has finished running and the Visualforce page has finished running, are the changes committed to the database. If the request does not complete successfully, all database changes are rolled back.

Sometimes during the processing of records, your business rules require that partial work (already executed DML statements) be “rolled back” so that the processing can continue in another direction. Apex gives you the ability to generate a savepoint, that is, a point in the request that specifies the state of the database at that time. Any DML statement that occurs after the savepoint can be discarded, and the database can be restored to the same condition it was in at the time you generated the savepoint.

The following limitations apply to generating savepoint variables and rolling back the database:

  • If you set more than one savepoint, then roll back to a savepoint that is not the last savepoint you generated, the later savepoint variables become invalid. For example, if you generated savepoint SP1 first, savepoint SP2 after that, and then you rolled back to SP1, the variable SP2 would no longer be valid. You will receive a runtime error if you try to use it.
  • References to savepoints cannot cross trigger invocations because each trigger invocation is a new trigger context. If you declare a savepoint as a static variable then try to use it across trigger contexts, you will receive a run-time error.
  • Each savepoint you set counts against the governor limit for DML statements.
  • Static variables are not reverted during a rollback. If you try to run the trigger again, the static variables retain the values from the first run.

  • Each rollback counts against the governor limit for DML statements. You will receive a runtime error if you try to rollback the database additional times.
  • The ID on an sObject inserted after setting a savepoint is not cleared after a rollback. Create an sObject to insert after a rollback. Attempting to insert the sObject using the variable created before the rollback fails because the sObject variable has an ID. Updating or upserting the sObject using the same variable also fails because the sObject is not in the database and, thus, cannot be updated.

The following is an example using the setSavepoint and rollback Database methods.



Account a = new Account(Name = 'xxx'); insert a;

System.assertEquals(null, [SELECT AccountNumber FROM Account WHERE Id = :a.Id].

                           AccountNumber);


// Create a savepoint while AccountNumber is null

Savepoint sp = Database.setSavepoint();


// Change the account number

a.AccountNumber = '123';

update a;

System.assertEquals('123', [SELECT AccountNumber FROM Account WHERE Id = :a.Id].

                             AccountNumber);


// Rollback to the previous null value

Database.rollback(sp);

System.assertEquals(null, [SELECT AccountNumber FROM Account WHERE Id = :a.Id].

                            AccountNumber);

Saturday, November 27, 2021

Set Up the Lightning Service Console

 

Set Up the Lightning Service Console

Learning Objectives

In this project, you’ll:

  • Create your own Service Console app.
  • Customize the Lightning Console pages.
  • Add Utilities to your Console.
  • Enable and utilize Live Agent.
  • Optimize the use of Omni-Channel.

Ada Balewa, a product support specialist at Ursa Major Solar, Inc., wants to optimize her customer service team’s productivity. Her Southwest US-based company, which supplies solar components and systems, has grown—and so has their volume of support cases. As Ursa Major Solar’s admin, you want to help them achieve their productivity goals by creating a Service Console for the team. The Service Console is a standard Salesforce Lightning console app that you can customize to meet the team’s case management needs, allowing them to access all things case-related, all from one screen. That’s pretty great!

Create a User and Enable Knowledge

Before you create Ursa Major Solar’s Service Console app, ensure that all of the settings are enabled for the tools you need to access in the service console. One of these tools is Salesforce Knowledge. Enable Knowledge for Ursa Major Solar.

If you’ve already completed the Set Up Salesforce Knowledge project in your playground, you can skip steps 1–9 in this section.

  1. Click the gear icon Setup iconand select Service Setup.
  2. From the Recommended Setup flows, click the Get Started button on the Add Your Users tile.
  3. Fill in the information:
    • Email (Username): ada.balewa@ursamajorsolar + your initials + today’s date (DDMMYY).com
    • First Name: Ada
    • Last Name: Balewa
    • Profile: Custom: Support Profile
  4. Click Add User, then Finish.
  5. Click View All under the Recommended Setup section.
  6. Click the Knowledge Setup tile.
  7. Click Start.
  8. From the Choose Your Lightning Knowledge Authors page, select Ada Balewa and yourself, and click Next.
  9. Click Next, then Finish.
Note

If you've used the maximum number of licenses allowed in your current playground, please deactivate one of the licenses and then add Ada. Alternatively, you can create a new playground.

Set Up the Salesforce Service Console in Lightning

Now that Knowledge is enabled, create Ursa Major Solar’s Service Console app, which serves as the center for case management. Use the Setup Flow to get started customizing all the features the Lightning Service Console has to offer.

  1. Click the gear icon Setup iconand select Setup.
  2. Enter App Manager in the Quick Find box, and select App Manager.
  3. Click the New Lightning App button and follow the screens to add the new app details.
  4. Fill in the App Details & Branding information.
    • App Name: Ursa Major Solar Service Console
    • Developer Name: (This field auto-populates.)
    • Description: Ursa Major Solar’s one-screen case management interface
    • App Branding: (You’re not adding a logo or branding at this time.)
  5. Click Next.
  6. On the App Options page, select Console Navigation and Service Setup.
  7. Click Next.
  8. On the Utility Items page, click Add Utility Item.
  9. Click History.
  10. Repeat steps 8-9 to add Macros and Open CTI Softphone. (More about these utilities later in this project.)

Ursa Major Solar Service Console customization screen showing History, Macros, and Phone Utilities added.

  1. Click Next.
  2. On the Navigation Items page, use CTRL/Command to select Accounts, Cases, Contacts, and Knowledge from the Available Items list, and click the arrow Arrow icon to add them to the Selected Items list.

Ursa Major Solar Service Console customization screen showing navigation items added.

  1. Click Next.
  2. On the Navigation Rules page, choose how the following open.
    • Accounts: Select the Workspace tabs radio button.
    • Cases: Select the Subtabs of radio button and choose Account (Account) from the picklist.
    • Contacts: Select the Subtabs of radio button and choose Account (Account) from the picklist.

Ursa Major Solar Service Console customization screen showing a navigation rule added.

  1. Click Next.
  2. On the User Profiles page, use CTRL/Command to select Custom: Support Profile and System Administrator, and click the arrow Arrow icon to add them to the Selected Profiles list.
  3. Click Save & Finish.

Test Your Work

You just used the Setup Flow to customize the Service Console for Ursa Major Solar. To see what the user experience is like for Ada and her team, go into the Service Console app you just created and click around to view the features you just built into it.

  1. Click the App Launcher App Launcher iconand select Ursa Major Solar Service Console.
  2. From the dropdown click Accounts.
  3. From the list view dropdown, select All Accounts.
  4. Click the Edge Communications account link under the name column.
  5. Note that the Accounts list view remains open on the left side of the console, and the account information for Edge Communications opens on the right, in the main workspace of the console. This is called split view. You can change this view to Kanban or back to Table by clicking List view icon under the Accounts list view palette. Now, leave it as split view.
  6. Scroll down and click Sean Forbes under the Contacts related list. The contact record for Sean Forbes opens as a subtab of the account.
  7. On the left side of the page, under the Accounts list view palette, click the Pyramid Construction Inc. account. The account record opens as a workspace tab on the right.
  8. Scroll down and click Pat Stumuller under the Contacts related list. The contact record for Pat Stumuller opens as a subtab of the Pyramid Construction Inc. account.
  9. Scroll down and click New under the Cases related list. The case record opens as a subtab, and the Account Name and Contact Name fields auto-populate.

If you’ve completed the Set Up Case Escalation and Entitlements project in your playground, you’ll be asked to select a record type. If required, select the Inquiry record type.

  1. Log a case by filling in the rest of the information.
    • Case Origin: Phone
    • Subject: Solar Panel Warranty
    • Description: What is the warranty on the Solar Panels when they get installed?
  2. Click Save.
  3. Click the History component in the utility bar at the bottom of the console to view your history. Click the arrow next to Pyramid Construction to expand the history for this account.

Great! You’ve set up the Service Console for Ada and her team. They’ll be able to access all the productivity tools and information needed to efficiently manage cases all from one screen. Next, customize the console to include all of the features and layouts that Ada and her team request.


How Service Cloud Makes Customers Happy

Customers love having their problems solved quickly. Here are some ways Service Cloud makes that happen.

  • Offer support everywhere and on any device. Connect with customers where they are—phone, email, SMS text, social media, webchat, web communities, messaging apps like WhatsApp, and more. Seamlessly switch conversations to any channel customers prefer to give them the best experience possible.

  • Send immediate responses to show that you care. Let customers know that you’ve received their issue by sending them automatic updates and messages. Personalize responses with customizable templates that give customers an ETA on an answer, solution, appointment, or field visit.

  • Auto-escalate important issues before they become emergencies. Add automatic workflows that flag key customers or concerns and forward them to managers by specific dates or times. Keep track of the status of critical service situations to prevent them from becoming nightmares.

How Service Cloud Improves Agent Productivity

Productive service agents help more customers and make a good impression on your brand. Here are a few ways Service Cloud makes your team more productive.

  • Support all channels from one screen. No matter how your customers contact you, your agents review and respond to each inquiry from one unified screen called the console. No fiddling with lots of windows. No endless scrolling or clicking to get to the next customer or channel. Everything agents need is right before them so they can focus on customers, not technology.

A service console with a customer’s data and phone channel

  • Route issues to the right person. Instead of guessing who should answer each question from which channel, automatically route all customers to the right agents, every time. Also, let integrated processes figure out priorities, workloads, and agent skills before connecting an agent with a customer.

  • Track key metrics for improvement. To find ways to upgrade your service, view regular snapshots of your team’s average first response times, average customer wait times, total customer interactions, and more. Make major and minor service decisions based on data.

Service Cloud gives you the tools you need to wow your customers and make your agents support geniuses. With each customer’s data available during any interaction, your team can ensure customer success more easily.

Community Cloud User Licenses

 The following licenses are used for external users: Customer Community, Customer Community Plus, Partner Community, External Apps, External Identity, and Channel Account.

How do community licenses compare to legacy portal licenses?
Here’s a quick correlation of the new communities licenses with their older portal counterparts and their main use case.
Important
IMPORTANT Users who have portal licenses can access your site as long as you include them by adding the profiles or permission sets that they’re associated with to your site. You don’t have to purchase new licenses for them, or swap them for communities licenses.
LICENSE NAMEBEST USED FORCOMPARABLE PORTAL LICENSE
External Apps

Custom digital experiences to engage any external stakeholder, including Brand Engagement and Customer Loyalty. Limited access to CRM objects. The External Apps license can be used with person accounts.

Note
NOTE Each External Apps (Members) subscription entitles the permitted number of member Users access to all such Communities within the same Org.
High Volume Customer Portal, Service Cloud Portal, Authenticated Sites Portal
Customer CommunityBusiness-to-consumer experiences with large numbers of external users who need access to case objects or knowledge. The Customer Community can be used with person accounts.High Volume Customer Portal, Service Cloud Portal, Authenticated Sites Portal
Customer Community PlusBusiness-to-consumer experiences with external users who need access to reports and dashboards and need advanced sharing. The Customer Community Plus can be used with person accounts.Customer Portal — Enterprise Administration, Customer Portal Manager Standard, Customer Portal Manager Custom
Partner CommunityBusiness-to-business experiences that need access to sales data such as partner relationship management. The Partner Community can’t be used with person accounts.Gold Partner
Channel AccountBusiness-to-business sites and portals that calculate their usage based on number of partners instead of number of individual users.Gold Partner
Note
NOTE Different license types can access your Experience Cloud sites. Your site isn’t limited to just one type of license.

steps for Salesforce Community Implementation

Steps to enable communities:-

Step 1.) From Setup, search for communities setting and click on it.

Step 2.) Click on New Community button to create a new community.

Step 3.) As soon as you select the checkbox, a new section would be prompted to select a domain name.  Remember, always choose your domain name very carefully, as once domain name is created it CANNOT be changed.

Yeah! that’s right, you can’t change your domain name once it is created.

After selecting domain name, click save and you are done.

Great! Now you can create multiple communities depending upon your license.

Steps to create a community:-

Once you have enabled the community, you can go ahead and create a new community and make it ready for customer use.

Let’s see what are the steps you need to perform to create a community from the scratch.

Step 1.) From setup, search for ‘All communities’ and select it.

Step 2.) Click on New Community button to create a new community.

Step 3.) The page shows the different predefined templates which you can use for your community depending upon your requirement. For example: If you are creating this community for customer support you can select Customer Service template OR if the community is meant for the portal user, select customer Account portal template. If you want to use your Standard or Custom objects in your community, you can go for Salesforce Tabs + Visualforce template. Also, if you want you can make and design your own templates.

Step 4.) After selecting the template, click on Get Started on next page.

Step 5.) Give a name to your community and provide a unique value at the end of the URL and click on Create button.

NOTE:- If you have multiple communities, you can create only one community that does not have a custom URL. Since the domain name is same for all communities, so a custom URL path differentiates them.

Hurray!! Congratulations, just now you have created a brand new Community in your Salesforce Org.

Now you would be redirected to the community workspace i.e. from workspace you can build and customize your community pages and its look and feel. You can manage the members of community.

Now the only thing you need to do is to activate the community and publish it so that everyone can use it to whom you want to use.

Activate the Community:-

To activate the community:-

Step 1.) Search for All Communities in setup, and click on it.

Step 2.) Click on Workspaces.

Step 3.) Select ‘Administration’.

Step 4.) Under ‘Setting’ section in left panel, click on Activate Community button.

Now, your community has been activated. But you need to publish the community.

Publish the Community:-

Step 1.) Search for All Communities in setup, and click on it.

Step 2.) Click on Workspaces.

Step 3.) Select Builder.

Step 4.) Click on Publish button on the top right corner of builder.

Now, your community is ready to use.

IMPORTANT:- After you create the community, your profile is now added to the list of available members to use community. So, it might possible that your profiles is being assigned to other users also, so they can also access community.