Salesforce Summer 17: Cool Seagulls in Summer

Hi everyone, we all know Salesforce release 3 updates for its system in a year.  Now Salesforce recently launched Summer 17. Summer is hot and in Rajasthan it’s very hot.  So here are few hot and exciting updates for everyone.

Summer_17_Release_Logo

  1. Use Advanced PDF to Render Visualforce Pages as PDF Files (Pilot)

Advanced PDF renders Visualforce pages as PDF files with broader support for modern HTML standards, such as CSS3, JavaScript, and HTML5. This change applies to both Lightning Experience and Salesforce Classic.

To use Advanced PDF, set renderAs=”advanced_pdf” in the tag of a Visualforce page with API version 40.0 or later. This process is similar to the existing process for rendering a Visualforce page as a standard PDF file.

PDF pages rendered with Advanced PDF are subject to the same limitations as legacy PDF pages, including the maximum page size and limited number of fetched resources. Advanced PDF pages also time out after rendering for 2 minutes, which includes asynchronous processing time.

  1. Roll Back Changes in Your Org When Remote JavaScript Methods Throw Exceptions

When a JavaScript method in an Apex class calling a remote action throws an exception, the action isn’t completed. Previously, when a method threw an exception, the action was completed.

For example, when you created an Apex class that used a remote action to add an account to your org and that method threw an exception, the account was added. Now, the account isn’t added. With this enhancement, JavaScript remoting methods that throw exceptions no longer cause changes in your org. This change applies to both Lightning Experience and Salesforce Classic.

  1. Cache Operations Supported in Visualforce Controllers

Cache operations made using the put and remove methods in the Cache Namespace are now supported in constructors and getter methods of Visualforce controllers.

  1. New Option for Parallel Testing on the isTest() Annotation

Use the @isTest(isParallel=true) annotation to indicate test classes that can be run in parallel and aren’t restricted by the default limits on the number of concurrent tests. This makes the execution of test classes more efficient, because more tests can be run in parallel.

  1. Deploy Changes Now Trigger Recompile of All Apex Code

All of an org’s Apex code is now automatically recompiled before completing a metadata deploy, a package install, or a package upgrade.

Previously, a deploy, install, or upgrade left the org with invalidated code, which sometimes caused recompilation errors when many Apex transactions occurred. This change in behavior improves performance following metadata deploys and package updates.

  1. Disable Access to Non-global Apex Controller Methods in Managed Packages (Critical Update)

This critical update corrects access controls on Apex controller methods in managed packages. When this update is enabled, only methods marked with the global access modifier are accessible by Lightning components from outside the package namespace. These access controls prevent you from using unsupported API methods that the package author didn’t intend for global access.

Prior to this update, non-global methods (that is, Apex controller methods that weren’t marked with the global access modifier) could be accessed by Lightning components outside of the package namespace.

  1. Metadata Access in Apex

If you’re an ISV creating apps that use custom metadata components, you can now access     metadata using Apex. This change applies to both Lightning Experience and Salesforce Classic.

During or after an install (or upgrade), your app can create or update metadata to let users configure your app. Use the new Metadata namespace for accessing metadata in Apex code. The Metadata namespace contains classes that represent metadata types and components as well as classes that let you retrieve or deploy metadata components in the subscriber org.

  1.   Salesforce Integrations: Taking Salesforce to the Next Level

Now you can connect Salesforce with Skype for Business , Gmail, Google Calendar and Microsoft Office 365. They are generally available in both Lightning and Salesforce classic. Nut some of them are only available in Lightning.

  1. Einstein Vision Is Now Generally Available

Sign up for Einstein Vision to receive 1,000 free predictions per calendar month. If you need more predictions, you can purchase them.

Getting an Einstein Platform account is the first step to accessing the API. Use the sign-up page to get an account. You can get an account in two ways.

  • Heroku—When you provision the Einstein Vision add-on, an Einstein Platform account is created for you.
  • Salesforce—Log in with your Salesforce credentials and create an account.

After you create an account, you download your private key file. Use this file to create an access token.

You can also try your hand on a Trailhead project to understand it better.

  1. Removed LockerService Restriction on instanceof in JavaScript

    Previously, Salesforce advised against using theinstanceof operator in JavaScript code when LockerService is activated. This restriction has been removed, except when checking arrays.

There are many more other update related to Lightning and Einstein. As I am also reading them in more details so I might make another post for them in depth. This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release.

Sign up now for a pre release org.

You can read release notes here. Let me know if I missed something here or if you want to add something then let me know in comments section.

Winter 17 is Here! A Quick Preview

Winter 17 is Here! A Quick Preview

Salesforce community is very busy these days. Dreamforce is near and everybody is preparing themselves for this mega event. As winter is here. So today I come up with 10 important feature of Winter 17

  1. Horizontal Navigation Comes to Lightning — One of the main initial features of Lightning, the collapsible side panel navigation, will be a thing of the past when Winter 17 goes live. This will be a big gain in efficiency and will ease the transition from Classic as it is similar to the Classic tabbed header. An awesome feature of the top navigation is when you hover over the tab name, you get a list of recent object records.
  2. Lightning Experience enhancements — Create Custom Apps in Lightning Experience and Navigate More Efficiently, Get Field-Level Help in Lightning Experience, Get Field-Level Help in Lightning Experience using save & New button
  3. Napili Is Now Called Customer Service (Napili) and it now supports more objects.
  4. Now you can use global search instead of Quick Find to find specific setup records, such as the Lead Source picklist or the Sales Rep profile. This feature is available in Lightning Experience only.
  5. Now you can create and manage your global picklist value sets from either user interface. No more switching back and forth to manage all of your picklists in Setup. Also Standard, multi-select picklists can be as detailed as you need them to be with a new limit of 255 characters per entry.
  6. The time window to quick-deploy your validations has expanded from 4 days to 10 days. This larger time window provides you more flexibility for scheduling your quick deployment and helps minimize the impact on your org.
  7. Build Reusable, Invocable Processes — This new feature will allow admins to create one Process and reuse it by invoking it from another Process. It’ll be available in Classic and Lightning editions.
  8. Inline Editing in List View Comes to Lightning —Lightning users will be able to hover over fields in a Listview and click to edit. This feature is in Beta and some restrictions will apply.
  1. Add the force:lightningQuickAction or force:lightningQuickActionWithoutHeader interface to a Lightning component to enable it to be used as a custom action in Lightning Experience or Salesforce1. You can use components that implement one of these interfaces as object-specific actions in both Lightning Experience and Salesforce1. You can use them as global actions only in Salesforce1.
  2. The Lightning Design System is now automatically added to your Lightning Out and Lightning Components for Visualforce apps. The Lightning Design System provides a look and feel that’s consistent with Lightning Experience.

 

Here are the 10 features which I found useful. I will keep updating this list whenever I found any useful feature in Winter 17 release notes. In the meantime you should give a read to Winter 17 notes and if found anything useful share them in comments. Cheers 🙂

Lightning in Salesforce – Part 3

Lightning in Salesforce – Part 3

In the previous post we learn how to use client side controller in lightning. In this post we will continue this with how to take input from user and process them between controller and save user inputs.

In lightning we have some native tags to get user inputs (Same as Visualforce tag or general HTML tag)


<ui:inputText aura:id="expname" label=" Account  Name"

value="{!v. account.Name}" required="true"/>

<ui:inputNumber aura:id="amount" label="Amount"

value="{!v. account.Amount__c}" required="true"/>

<ui:inputDate aura:id="expdate" label="Meeting  Date"

value="{!v. account.Date__c}" displayDatePicker="true"/>

<ui:inputCheckbox aura:id="reimbursed" label="Reimbursed?"

value="{!v.account.Reimbursed__c}"/>

<ui:button label=”Create Account” press=”{!c.clickCreateRecord}”/>

Then in the button click we will pass this data into controller for processing


clickCreateExpense: function(component, event, helper)

and now we can use helper to do some processing.


helper.createExpense(component, account); //account is instance of account

But now to save this we need to call apex controller. In apex we will use this format. So to call apex methods in Lightning we will follow this format

</pre>
@AuraEnabled

public static List<account > getaccount()
<pre>

Use @Auraenabled to access this method in Lightning. All method must be static so it’s stateless communication and faster then Visualforce Apex communication.

 

To get data from apex in lightning

// Load expenses from Salesforce

doInit: function(component, event, helper) {



// Create the action

var action = component.get("c.getaccount");

// Add callback behavior for when response is received

action.setCallback(this, function(response) {

var state = response.getState();

if (component.isValid() && state === "SUCCESS") {

component.set("v.account", response.getReturnValue());

}

else {

console.log("Failed with state: " + state);

}

});

// Send action off to be executed

$A.enqueueAction(action);

},

We will follow this approach to pass data in apex controller

createAccount: function(component, account) {

var action = component.get("c.saveAccount");

action.setParams({

"account": account

});

action.setCallback(this, function(response){

var state = response.getState();

if (component.isValid() && state === "SUCCESS") {

var accounts = component.get("v.accounts");

accounts.push(response.getReturnValue());

component.set("v.accounts", accounts);

}

});

$A.enqueueAction(action);

},

Here we use setparams to pass the parameter in apex and then use them in our code. So now we have good idea of how to pass data between Lightning and apex. So the last point in our journey is Events.

Event is used to pass data between one component and another.

In the Developer Console, select File | New | Lightning Event, and name the event “testEvent”

var createEvent = component.getEvent("testExpanse");

createEvent.setParams({ "account": newAccount });

createEvent.fire();

We will use fire() to fire the event and

 var newAccout = event.getParam("account"); 

is used to catch the events.

So here we cover all basic and starting points for development in sLightning. In my next post we will cover some advance uses of Lightning.

Do you have anything to say or want to add anything useful. Please share them in comments.

Lightning in Salesforce – Part 2

Lightning in Salesforce – Part 2

In the previous post we have discussed what is Lightning, Lightning app and some other basic details. In this post we will continue with Lightning component.

To create Lightning component first go to developer console select File | New | Lightning Component to create a new Lightning component. In the New Lightning Bundle panel, enter HelloWorld for the component name, and click Submit.Component

 

Now add this lightning component in the lightning app to view this in browser. A component is a bundle that includes a definition resource, written in markup, and may include additional, optional resources like a controller, stylesheet, and so on. A resource is sort of like a file, but stored in Salesforce rather than on a file system.

We will write our complete code in the lightning components.

Now we will learn to add attribute and expression this is a same process which we use in visual force components.


<c:helloMessage message="You look nice today."/>

Here message is an attribute and we will display it using component.


<aura:component>

<aura:attribute name="message" type="String"/>

Hello! {!v.message}

</aura:component>

This is a component body (looks similar to Visualforce component isn’t it).

Note: to display data we use v. expression format and this will remain same in all places. V is something called a value provider. Value providers are a way to group, encapsulate, and access related data. An expression is basically a formula, or a calculation, which you place within expression delimiters (“{!” and “}”). So, expressions look like the following:

{!<expression>}

 

You can also use labels and other text in expression


{!$Label.c.Greeting + v.message}

There are a number of different attribute types.

  1. Primitives data types, such as Boolean, Date, DateTime, Decimal, Double, Integer, Long, or String. The usual suspects in any programming language.
  2. Standard and custom Salesforce objects, such as Account, MyCustomObject__c.
  3. Collections, such as List, Map, and Set.
  4. Custom Apex classes.
  5. Framework-specific types, such as Aura.Component, or Aura.Component[].

 

Now we will learn how to use controllers.

Lightning component work on View-Controller-Controller-Model, or perhaps View-Controller-Controller-Database. Here two controller refer, one client side controller (JavaScript) and other is server side controller (Apex).


<ui:button label="You look nice today." press="{!c.handleClick}"/>

So when we click this button an event will fire (Same as Visual force) but instead of controller method we will first call client side controller or JavaScript controller.


({

handleClick: function(component, event, helper) {

var btnClicked = event.getSource();         // the button

var btnMessage = btnClicked.get("v.label"); // the button's label

component.set("v.message", btnMessage);     // update our message

}

})

This is the JavaScript controller format. Here event is which start this process. Component contains information related to the component in which this event is fired and helper is as name suggests a helper method which we can call multiple time in component.


handleClick2: function(component, event, helper) {

var newMessage = event.getSource().get("v.label");

component.set("v.message", newMessage);

},

handleClick3: function(component, event, helper) {

component.set("v.message", event.getSource().get("v.label"));

}

You can define multiple method but you need to separate them using comma. You can also use JavaScript debugging tools like console.log here to debug the application. In the next post we will learn how to take input from users and pass them in controllers.

Lightning in Salesforce – Part 1

Lightning in Salesforce – Part 1

We all are aware of Lighting and if not then we should. Because with every release Salesforce giving more focus to lightning. Lightning is the future (don’t worry Apex and Visual force will still available).

Those who don’t know what Lightning is for them “Lightning Components is a UI framework for developing web apps for mobile and desktop devices. It’s a modern framework for building single-page applications with dynamic, responsive user interfaces for Force.com apps. It uses JavaScript on the client side and Apex on the server side.”

lex_dev_lc_basics_architecture

 

Using lightning you can create Drag and drop component, Stand alone app, Run them in Visualforce page, Run them on other platform using lightning out and appexchange apps too. There are many good posts available on Internet and many resources too. So in this post (of series) I will pick short module and explain them separately. So that user can combine and use them as per their requirement.

So before we start here are some prerequisite:

  1. Create new Developer account.
  2. Enable custom domain and rollout this for user.
  3. Get basic Idea of JavaScript.

Now we will start the modules. In this series of post we will cover following thing.

  1. Lightning App
  2. Lightning component
  3. Attribute and expression
  4. Controller( JavaScript and apex)
  5. Use of helper
  6. Events

First we will start with Lightning App

Open the developer console and Select File | New | Lightning Application to create a new Lightning app. In the New Lightning Bundle panel, enter TestApp for the app name, and click Submit.

App contains the opening and closing tags for a Lightning app, <aura:application>. Between them, we will add all component and Save the app so that we can view the result.

APPPreview

 

The main items of an app are the following.

  1. When writing markup, you can add a component to an app, but you can’t add an app to another app, or an app to a component.
  2. An app has a standalone URL that you can access while testing, and which you can publish to your users. We often refer to these standalone apps as “my.app.”
  3. You can’t add apps to Lightning Experience or Salesforce1—you can only add components.

In the next part we will continue with Lightning components.

Process Builder: A Handy Tool

The Process Builder is a workflow tool that helps you easily automate your business processes by providing a powerful and user-friendly graphical representation of your process as you build it. The Process Builder’s simple and powerful design allows you to:

  • Create your processes using a convenient layout with point-and-click efficiency.
  • Create your whole process in one place rather than using multiple workflow rules.
  • Create processes by collaborating with different teams in your business.
  • Stop using Apex code to automate simple tasks. Like update child record from parent.
  • Stop worrying about test classes and their coverage.Bz5Y5AxCcAIG14g.jpg
Automated processes in the Process Builder are based on records and consist of:

  • Criteria that determine when to execute action groups.
  • Immediate and scheduled actions to execute when those criteria are met.

Any change that causes a record to match the criteria can automatically trigger the action group.

You can use the more powerful and flexible Process Builder to perform the same actions as workflow. The process builder doesn’t support outbound messages, but you can easily create one yourself with Apex. With the Process Builder, you can:

  • Create a record
  • Update any related record—not just the record or its parent
  • Use a quick action to create a record, update a record, or log a call
  • Launch a flow—you can’t schedule this action with workflow
  • Send an email
  • Post to Chatter
  • Submit for approval

If you need your process to do more than what those actions allow, don’t worry. You can also call Apex from a process.

Here is a basic comparison between Workflow, Visual Flow and the Process Builder

Workflow

Workflow enables you to set up workflow rules that identify what kinds of record changes or additions trigger specified workflow actions, such as sending email alerts and updating record fields.

Visual Workflow

Visual Workflow enables you to create flows, which are applications that are user-triggered instead of event-triggered. Unlike Workflow, which always executes rules and actions behind the scenes, Visual Workflow offers screens for displaying and collecting information from the user running the flow.

Process Builder

Process Builder can be utilized to automate all workflow actions (with the exception of outbound messages). Traditional workflow can still be utilized in parallel, however, Process Builder gives you the ability to do things that workflow can’t. Although, somewhat of a double edged sword this puts some very powerful tools at the disposal of an experienced administrator.

 

If you want to learn more here are some tools which you can use.

TrailHead Process Builder

Which Automation Tool Should I Use?