Salesforce Spring 18: Quick Preview

Salesforce Spring 18: Quick Preview

Happy New Year Everyone. And god bless to them who had hardcoded 2017 in there code. Salesforce has just release Spring 18 and this time also the main focus remains n Einstein and Lightning. In this release there are many good feature are introduced. So let’s take a quick look at them.

spring-18-logo-268x300
Spring 18
  1. Gather Feedback with Salesforce Surveys (Generally Available)

Salesforce now has introduced Surveys. Create beautiful, easy-to-use forms for collecting feedback and data from your users or customers. Add different types of questions to gather the data you need. All your valuable survey data is stored in your org, so you can harness the power of Salesforce to view data, create reports and dashboards, and share insights with your company.

  1. Enable the New URL Format for Lightning Experience and the Salesforce

Salesforce is changing the URL format used by Lightning Experience standard apps and the Salesforce mobile app. The new URL format is more readable and addresses the issue of being directed to an unexpected location when accessing Lightning Experience URLs before authenticating. This update doesn’t apply to console apps and communities.

For example:

Custom or installed Lightning components that parse a URL may break or behave differently after this change, especially components with logic that relies on window.location or the aura:locationChange event.

  1. Einstein

Einstein Opportunity Scoring: Artificial Intelligence for Opportunities (Generally Available)

Salesforce has expanded the Sales Cloud Einstein product suite with Einstein Opportunity Scoring. Now we can prioritize our way to more business. This feature is new in Lightning Experience and Salesforce Classic.

Einstein Forecasting: Intelligent Predictions About our Sales Teams (Beta)

Let Einstein take the guesswork out of forecasting. Use artificial intelligence to get more certainty and visibility into how your sales teams are doing. This feature is new in both Lightning Experience and Salesforce Classic.

Einstein Lead Scoring: Clearer Predictive Factors and Detection of Rank and Department

Get a clearer view of the reasons behind each score. And see better scores with rank and department information. These changes apply to both Lightning Experience and Salesforce Classic.

Einstein Insights: Access Account and Opportunity Insights from Your Mobile Device (Pilot)

Einstein Insights are now. See predictions about which deals are likely to be won, reminders to follow up, and notifications when key moments in a deal take place. Reps can take action directly from the insights, including editing the related record or sending emails to relevant contacts. This change applies to Salesforce for iOS and Salesforce for Android.

Einstein Platform Services APIs

Use the Einstein Platform Services APIs to easily AI-enable your apps with image recognition and natural language processing. Using the Einstein Vision APIs, you can leverage pre-trained classifiers or train your own custom classifiers to solve a vast array of specialized image recognition use cases. With the Einstein Language APIs, you can harness the power of natural language processing to analyze text and infer the sentiment or intent behind that text. Make your apps smarter, and look like a genius at the same time.

  1. Stay on Top of Duplicate Records by Using Duplicate Jobs PERMISSIONS

Good clean data builds the trust of your sales team. It also helps you work toward complying with various data protection and privacy regulations. So you’ve got everything to gain by getting a global view of duplicate records. Use duplicate jobs with standard or custom matching rules to scan your Salesforce business or person accounts, contacts, or leads for duplicates. Share job results with others and merge the duplicates—all within Salesforce. Use information about duplicate jobs we’ve run to track the progress in reducing duplicate records. This feature is new in Lightning Experience.

  1. Salesforce IoT: IoT REST API, New Context UI, IoT Usage Monitoring, and Email Alerts

Use Salesforce IoT Explorer Edition to process events from connected devices in near real time and create meaningful interactions with your customers. Explorer offers built-in integration with Salesforce data and lets you leverage your Customer Relationship Management (CRM) investments in Salesforce. This release includes a new IoT REST API to retrieve and manipulate orchestrations and their related components, and a new user interface for contexts. Also, Salesforce is introducing an IoT usage monitoring page, email alerts, and the ability to export and delete IoT data for data privacy.

  1. Use without sharing for @AuraEnabled Apex Controllers with Implicit Sharing (Critical Update)

This critical update changes the behavior of @AuraEnabled Apex controllers that don’t specify with sharing or without sharing to default to without sharing. This change relaxes the security for controllers that don’t explicitly set sharing behavior using these keywords. It’s a best practice to always use with sharing in Apex controllers used with Lightning components.

  1. Find Dynamically Created Components

We can now use cmp.find() to find a component that we have create dynamically with $A.createComponent().

  1. Remove Instance Names from URLs for Visualforce, Community Builder, Site.com Studio, and Content Files (Critical Update)

Salesforce is stabilizing the hostname of Visualforce, Community Builder, Site.com Studio, and content file URLs by removing instance names from URLs. This critical update applies to orgs that have a deployed My Domain. It will be activated automatically on March 16, 2019.

Prior to Winter ’18, Visualforce, Community Builder, Site.com Studio, and content file URLs included the instance name of the org, even when a My Domain name was deployed. An instance name identifies where your Salesforce org is hosted. When Salesforce remove the instance name from our URLs, hostnames change.

Here are two examples:

  • mydomain–c.visualforce.com replaces mydomain–c.na1.visual.force.com
  • mydomain–c.documentforce.com replaces mydomain–c.na1.content.force.com

Note: All *.content.force.com URLs will be replaced with *.documentforce.com.

  1. Employ Validation Rule Formulas with Custom Metadata Types

If we use validation rules, you know how helpful they can be, but you have to hard code some of the values. Now you can store values you previously had to hard code in custom metadata types and reference them in your validation rules.

Example: Use a validation rule formula to limit discounts on certain brands to 10%. You can use validation rules without custom metadata. However, to change an amount, you must update the hardcoded value. If you have multiple validation rules that check the discount amount, you have to manage all of them. Instead, use a validation rule formula with custom metadata types.

  1. Create a custom metadata type. In this example, we named it DiscountLimits.
  2. Create a custom field for your type. We named it maxDiscount.
  3. Create a record. We named it FoodDiscount.

When done, you can reference the custom metadata type in your validation rule. The syntax is:

$CustomMetadata.CustomMetadataTypeAPIName.RecordAPIName.FieldAPIName

Make sure to use the correct suffixes. For the custom metadata type, use __mdt. For fields, use __c. Records require no suffix.

Your validation rule for this example looks something like this:

Discount > $CustomMetadata.DiscountLimits__mdt.FoodDiscount.maxDiscount__c

  1. In Spring 18 Salesforce added two new methods in list class. They are

contains(listElement)

Returns true if the list contains the specified element.

indexOf(listElement)

Returns the index of the first occurrence of the specified element in this list. If this list does not contain the element, returns -1.

So now we no longer dependent on set to check for duplicate key at the same time we can maintain order as well.

  1. Collect Debug Logs for Guest Users Without Setting Cookies

In Winter ’17, Salesforce introduced a change that required guest users to set browser cookies to activate debug logging. people didn’t like the Winter ’17 change. Setting cookies is complicated, and the change made collecting debug logs for public users’ asynchronous activity impossible. Now public users no longer need a debug_logs browser cookie to trigger logging. This change applies to both Lightning Experience and Salesforce Classic.

  1. Avoid Huge Debug Logs for Managed Package Code

Debug logs no longer include ENTERING_MANAGED_PKG events when your log level for the Apex Code category is INFO or DEBUG. To log ENTERING_MANAGED_PKG events, set your Apex Code log level to FINE, FINER, or FINEST.

Advertisements

Einstein Object Detection: A Quick Overview

Einstein Object Detection: A Quick Overview

Einstein is now a known tech in market and Salesforce now making its library public from the beta mode. Recently Salesforce made Object Detection public available. Object Detection tells you where one or more objects are in an image which allows you to get specific counts and locations of objects within images.

For Object Detection first you need to train the Dataset. The process of dataset creation is bit different then the Einstein Vision.

To train an Einstein Object Detection model, you must provide the coordinates of the bounding boxes around the objects you want detected.  Draw a box around the object you want detected in the image, this is called a bounding box. For training you need the x/y pixel coordinates of the top left edge of that box, as well as the pixel width and height. You can have multiple objects within a single example image.

Once you’ve collected all of your example images and object data, you create a file with the name annotations.csv. This file is a key part of the Einstein Object Detection training. It tells the Einstein Platform where in your sample data it will find the objects it needs to pay attention to during training.

OD1.png

This is how the sample file will look. For the demo purpose I have used the same file used in Einstein Site. After the dataset is created you need to train It. This process is same as Einstein Vision. And once the dataset is trained you are ready to make your first request  find the object details.

First we need to create the dataset.

HttpRequest req = new HttpRequest();
 req.setMethod('POST');
 req.setEndpoint('https://api.einstein.ai/v2/vision/datasets/upload');
 req.setHeader('content-type', 'multipart/form-data; charset="UTF-8"; boundary="1ff13444ed8140c7a32fc4e6451aa76d"');
 req.setHeader('Authorization', 'Bearer <TOKEN>');

 req.setHeader('Cache-Control', 'no-cache');
 // Compose the form
 string form64 = '';

form64 += HttpFormBuilder.WriteBoundary();
 form64 += HttpFormBuilder.WriteBodyParameter('path', 'https://einstein.ai/images/alpine.zip');
 form64 += HttpFormBuilder.WriteBoundary();
 form64 += HttpFormBuilder.WriteBodyParameter('type', 'image-detection');
 form64 += HttpFormBuilder.WriteBoundary(HttpFormBuilder.EndingType.CrLf);

blob formBlob = EncodingUtil.base64Decode(form64);
 string contentLength = string.valueOf(formBlob.size());

 req.setBodyAsBlob(formBlob);
 req.setHeader('Connection', 'keep-alive');
 req.setHeader('Content-Length', contentLength);
 req.setTimeout(60*1000);

Http h = new Http();
 String resp;
 HttpResponse res = h.send(req);
 resp = res.getBody();
 system.debug(resp);
 Map<String,object> responseMap =(Map<String,object>)JSON.deserializeUntyped(res.getBody()) ;

As this is a Asynchronous process so we need to check the status of dataset creation. For this we need to make another request

HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setEndpoint('https://api.einstein.ai/v2/vision/datasets/&amp;amp;amp;amp;amp;amp;lt;DATASET ID&amp;amp;amp;amp;amp;amp;gt;');
req.setHeader('Authorization', 'Bearer <TOKEN>');
req.setTimeout(60*1000);

Http h = new Http();
String resp;
HttpResponse res = h.send(req);
resp = res.getBody();
system.debug(resp);

Now after our dataset is created we need to train the dataset.

HttpRequest req = new HttpRequest();
req.setMethod('POST');
req.setEndpoint('https://api.einstein.ai/v2/vision/train');
req.setHeader('content-type', 'multipart/form-data; charset="UTF-8"; boundary="1ff13444ed8140c7a32fc4e6451aa76d"');
req.setHeader('Authorization', 'Bearer <TOKEN>');

req.setHeader('Cache-Control', 'no-cache');
// Compose the form
string form64 = '';

form64 += HttpFormBuilder.WriteBoundary();
form64 += HttpFormBuilder.WriteBodyParameter('name','Alpine Boxes on Shelves');
form64 += HttpFormBuilder.WriteBoundary();
form64 += HttpFormBuilder.WriteBodyParameter('datasetId', '<DATASET ID>');
form64 += HttpFormBuilder.WriteBoundary(HttpFormBuilder.EndingType.CrLf);

blob formBlob = EncodingUtil.base64Decode(form64);
string contentLength = string.valueOf(formBlob.size());

req.setBodyAsBlob(formBlob);
req.setHeader('Connection', 'keep-alive');
req.setHeader('Content-Length', contentLength);
req.setTimeout(60*1000);

Http h = new Http();
String resp;
HttpResponse res = h.send(req);
resp = res.getBody();
system.debug(resp);

As this is also asynchronous process we we need to check the status.

HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setEndpoint('https://api.einstein.ai/v2/vision/train/&amp;amp;amp;lt;MODEL ID&amp;amp;amp;gt;');
req.setHeader('Authorization', 'Bearer <TOKEN>');
req.setTimeout(60*1000);

Http h = new Http();
String resp;
HttpResponse res = h.send(req);
resp = res.getBody();
system.debug(resp);
</pre>
Now once our Model training is completed we are ready to make our request. For testing purpose we will use this image.&nbsp;<img class="alignnone size-full wp-image-664" src="https://newstechnologystuff.files.wordpress.com/2017/12/alpine.jpg?w=680" data-wpmedia-src="https://newstechnologystuff.files.wordpress.com/2017/12/alpine.jpg" alt="alpine" width="4032" height="3024" data-mce-src="https://newstechnologystuff.files.wordpress.com/2017/12/alpine.jpg?w=680">
<pre>HttpRequest req = new HttpRequest();
req.setMethod('POST');
req.setEndpoint('https://api.einstein.ai/v2/vision/detect');
req.setHeader('content-type', 'multipart/form-data; charset="UTF-8"; boundary="1ff13444ed8140c7a32fc4e6451aa76d"');
req.setHeader('Authorization', 'Bearer <TOKEN>');
req.setHeader('Cache-Control', 'no-cache');
// Compose the form
string form64 = '';
form64 += HttpFormBuilder.WriteBoundary();
form64 += HttpFormBuilder.WriteBodyParameter('sampleLocation','http://einstein.ai/image/alpine.jpg');
form64 += HttpFormBuilder.WriteBoundary();
form64 += HttpFormBuilder.WriteBodyParameter('modelId', '&amp;lt;MODEL ID&amp;gt;');
form64 += HttpFormBuilder.WriteBoundary(HttpFormBuilder.EndingType.CrLf);
blob formBlob = EncodingUtil.base64Decode(form64);
string contentLength = string.valueOf(formBlob.size());
req.setBodyAsBlob(formBlob);
req.setHeader('Content-Length', contentLength);
req.setTimeout(60*1000);
Http h = new Http();
String resp;
HttpResponse res = h.send(req);
resp = res.getBody();
system.debug(resp);

The result we get is

{{ "probabilities": [ { "resultType": "DetectionResult", "label": "Alpine - Oat Cereal", "probability": 0.9947397, "boundingBox": { "minX": 2112, "minY": 916, "maxX": 2880, "maxY": 1933 } }, { "resultType": "DetectionResult", "label": "Alpine - Corn Flakes", "probability": 0.9945168, "boundingBox": { "minX": 791, "minY": 915, "maxX": 1540, "maxY": 1853 } }, { "resultType": "DetectionResult", "label": "Alpine - Bran Cereal", "probability": 0.9940328, "boundingBox": { "minX": 2873, "minY": 848, "maxX": 3629, "maxY": 1945 } }, { "resultType": "DetectionResult", "label": "Alpine - Bran Cereal", "probability": 0.9933943, "boundingBox": { "minX": 1433, "minY": 918, "maxX": 2156, "maxY": 1957 } } ]}

So you can check we got the correct result with 99+ probability. So this is very important feature of lightning which one can use in real life in sore to detect inventory, Parts etc.

So tell me in comments section what did you like most about Einstein. Happy Programming 🙂

Salesforce Einstein Intent: A Quick Overview

Salesforce Einstein Intent: A Quick Overview

Hi All, As Dreamforce is over and there are lots of new things in the market. but Einstein is on top of that. In my previous post I have already shared about Einstein Vision to predict the image. Today we will cover the basic of Einstein Intent A search Prediction.

You can use Einstein Intent to make a case prediction and route the case to different user  so that case can be solved much faster with less human intervention.

3342fe7-intent_and_sentiment_flow.png

The process is same as we have done for Einstein Vision. First if you don’t have API key or access token then you need to create one. You can follow the same steps as previous post.
After that we first need to create sample Dataset. In this step, you define the labels that you want the model to output when text is sent into the model for prediction. Then you gather text data for each of those labels, and that text is used to create a model.

You can use sample CSV which I have used or can create your own as well.

Then you need to train that dataset. You can also make request to check status of training. and once training is completed you can make your first prediction.

The text which I used for prediction is “Why my shipping address is changed.” And the response which I get is

Prediction Result.png

 

Its related to Billing and it is Correct. You can create large dataset to make these prediction more accurate. And can play with it yourself.

Let me know what you like most about Einstein in comments. If you want to add something share with me in comments section.

Happy Programming 🙂

Salesforce Einstein Vision: Quick Overview

Salesforce Einstein Vision: Quick Overview

Einstein Vision is part of the Einstein Platform Services technologies, and you can use it to AI-enable your apps. Leverage pre-trained classifiers, or train your own custom classifiers to solve a vast array of specialized image-recognition use cases. Developers can bring the power of image recognition to CRM and third-party applications so that end users across sales, service, and marketing can discover new insights about their customers and predict outcomes that lead to smarter decisions.

Einstein Vision includes these APIs:

  • Einstein Image Classification—Enables developers to train deep learning models to recognize and classify images at scale.
  • Einstein Object Detection (Pilot)—Enables developers to train models to recognize and count multiple distinct objects within an image, providing granular details like the size and location of each object.

0089e22-vision_terms_graphic.png

Today we will cover the Einstein Image Classification . As we have a very good Apex wrapper provided by Salesforce dev team here. Which you can use to make all request of Einstein while it handle all the heavy work in background for you.

But if you don’t want to install a full library to test these requests then I will share quick code sample which you can use to create your own request.

Before we start first you need to make sure that you have completed all prerequisite steps. You need a valid Einstein token to call API and few base classes to make request.

After all this setup our org is ready to make our first prediction. For our demo purpose we will use Bike vs Car model. Here I have commented Token Id, Dataset Id and Model Id you can enter your related Id there.

First  to make a request we need the access token, Here we take help of our base classes which we have included. To get the access token we will use JWT access token helper.

 

Then we need to make our Dataset: A data set is a folder which contains the images. Here we pass the data in multipart/form-data format.

Dataset can be created Asyn or syn. In our example we are creating Asynchronously.

Next we will train our dataset to identify the images. You will get Dataset ID from previous request.

this command train the Dataset and create a Model. Model creation process takes time based on number of images which you have provided. In our example number of picture is less so it will complete early.

You can also check the status

Once the Dataset is trained we are ready to make our first prediction.

For prediction we will use this image

18

 

And the response we get is

Screenshot_2.png

 

So we get Almost 100% for this image. You can make your own Dataset and can play with them.

Let me know what you like most about Einstein in comments. If you want to add something share with me in comments section.

Happy Programming 🙂

IOT And AI: The future is here

Salesforce with 3 release in a year also introduce many more products from time to time to use the latest technology  to keep it system updated and fast. While the current major thing is Lightning, Salesforce recently introduce two more products and actively working on them. They are Internet of Thing and Artificial Intelligence.

As everyone is aware these two things are major part of IT industry and in upcoming year so salesforce Introduce them for its CRM.  So I everyone should start learning these technology because they are the future and as a Developer we need to keep ourself updated.

IOT: Salesforce IoT Cloud is powered by Thunder, a scalable event processing engine, designed to ingest and analyze billions of events. Events are the data that comes from the networked devices and objects we talked about above. On top of that, Thunder lets you take personalized actions based on these events, which help your company create more enriching and focused customer experiences.

salesforce-iot

IoT Cloud’s way of taking in data and triggering actions to create experiences lets your company focus on creating engaging, individualized experiences for all your customers. These might be customized alerts, emails, or messages. Or the actions might be something else within Salesforce, like creating a service ticket, or customizing the information they access through an app.

Imagine a world where you can react to real-time information, quickly creating these interactions with all your customers, so that the experiences feel personal, specific, and at the right time. Well, imagine no more. Buckle up for a quick flight to the land of IoT.

Artificial Intelligence:  AI is the concept of having “machines think like humans.” You’re starting to see examples of AI in your everyday life because we’re at an evolutionary tipping point. AI isn’t a new concept—we’ve had the theoretical models for a long time—but it’s finally possible thanks to the access and increase in large amounts of data combined with the low cost of high-power computing.

en-usc0d1ba1f59e62557189904ee48b34c4e

AI has benefits for all parts of the business. Sales reps no longer have to enter sales data manually. Marketers no longer have to use manual A/B testing to select the best social media images for their next campaign. And customer service managers no longer have to sift through long lists of incoming service calls to prioritize their time.

AI will impact each and every part of CRM and with Einstein  it will make many thing smooth as well because in the bunch of leads it will show most important Leads on top, Notify you to follow from customer and send them reminder email and many other things as well. AI will act like personal Assistance available at anytime anywhere in your fingertip. AI with CRM make Salesforce CRM a smart CRM.

So this is a brief idea of what IOT and AI is but in near future they play an important part and this will make them a must learn thing. So include them in your learning or TO DO list and let me know in comments what things you like most about these and what improvement you want to see in them.