Tuesday 13 September 2016

Introducing Lightning Base Components

Lightning Base Components are great addition to the platform and in fact revolutionary .One of the concerns around lightning component development had been need to write too many lines of code and wire lot of JavaScript code for simple things like handling check boxes ,select list ,validations and so on .Having a base component library is certainly great first step . 

Lightning Base Components introduced in winter 17 release is documented here .Please note that many of these components are in BETA mode .

One of the things as a Visualforce developer I found harder when I was new to development was documentation did poor job to help imagine the UI and how the components will render  .I see the same issue with lightning components developer guide .

While the base components are listed and sample code is shown ,still to my fellow designers I am sure this is night mare to imagine or even for developers there will need to copy paste the code and preview how the markup renders which is definitely not respecting their time .

I quickly made a small documentation that would help the designers as well .

Here is the link to the documentation on git 


Here is a small unmanaged package in case you want to play around with all components 

The package contains all components inside a simple lightning App Page 


Note that there is lot of attributes that provides ability to do lot of Javascript actions declaratively  and  we will dig into each one of them via separate blogpost where I will test each of them and leave my experience and feedback .
 

 

Wednesday 3 August 2016

Automatic GeoCoding Feature In Salesforce - Summer 16


Summer 16 provided an excellent feature to the force.com platform of automatic adding GeoCodes to the address Data .The Feature is currently available for addresses on existing and new accounts, contacts, and leads and in salesforce classic .

With Location aware Data one can build  very cool visualization and help business achieve its goals .

I have a very interesting business scenario and lets discuss how we are going to solve the use case with this new feature

Business Use Case

Universal Containers is planning to hire sales folks and since they are global they want to hire sales folks in countries where there are maximum no of leads located so that they can reach out in person and demo their products .

Sales VP requested a plot of leads location on the world map so that he can start his hiring strategy .

Also  marketing VP wanted to know areas where there are no leads so he can focus his campaigns in those areas .

Enable Data Clean Feature


Enabling the Automatic Geolocation mapping for address requires you to enable setting a clean rule in data.com settings .Please check below screenshot



 



 Solution

We will use a Javascript plugin to build our map and use salesforce location aware lead data to plot as noticeable points on the map

There are many Javascript plugins that can provide you ability to create maps .For this blogpost I will be using AMCharts  

AmCharts has very cool features and with simple Javascript you can get a working app .

The Finished Solution looks like below
  
                        
    The data is fed back via apex controller logic . We will create a Wrapper class so that its easier to point this map to a different object later ,if needed 

 


Conclusion


Clearly looks like currently  leads are located at South Easter region of United States and VP of sales needs Sales Rep in this region .Also looks like marketing needs lot of work to focus other territories apart from US .

Location aware data can clearly help your business .If you are using salesforce platform ask your VP and C level executives if visualizing data on maps help them to achieve their goals then with this feature your developers can build some cool stuff .

Tuesday 28 June 2016

TLS 1.0 has been disabled For Sandbox - Salesforce

Salesforce has finally disabled TLS 1.0 in sandboxes .This is in preparation for disablement later in 2017 for PRODUCTION instances .

Now this would have not impacted your integrations in PRODUCTION org but if your integration is broken in your sandbox ,this means you have only few months to sort this and fix before this affects your integration for PROD live users .

Before we deep drive on how to possibly fix this and work with your external systems to figure solution ,lets first understand what is TLS and why did SFDC moved to 1.x and had to disable TLS 1.0

TLS 1.0 Explained
























TLS 1.1 Improvements 

  • Added protection against cipher-block chaining (CBC) attacks.
  • Support for IANA registration of parameters.


Clearly TLS 1.1 is more secure(Compared to 1.0) and protects salesforce resources against CBC attacks .

Identify if this change broke anything .The things that can be affected in your instances are as below
  1. Web requests to Salesforce URLs that require authentication
  2. Web requests to the login page of a My Domain
  3. Web requests to Community or Force.com sites
  4. Web requests to Customer and Partner portals
  5. Web to lead, web to case, and web to custom object requests
  6. API requests to Salesforce
  7. Callouts using Apex to a remote endpoint
  8. Workflow outbound messaging callouts to a remote endpoint
  9. Callouts using Lightning Connect to a remote endpoint
  10. AJAX proxy callouts to a remote endpoint
  11. Delegated authentication callouts to a remote endpoint
  12. Mobile apps developed with Salesforce Mobile SDK need to upgraded to SDK v4
That's a big list and if you are an enterprise org ,then I am sure you would have at least one of the above things in your org and you may find it to be broken .

The most common complains that I have received and encountered myself has been our IDE no more able to authenticate or our eclipse no more working ,or our migration tools are affected .

An example screenshot of error I got last night working with my ANT tool is as below






So below are some of the suggestions to fix this issue,

1. If you are using force.com migration tool and ANT process be on a latest ANT version -atleast 36.0
2.If you are using Java 7 ,upgrade to Java 8 since Java 8 by default uses 1.2 
3.If have an integration running on a webserver ,there will be setting to disable TLS 1.0 
4.You can disable TLS 1.0 in your browser 

5.Look for specific configuration if you want to explicitly force tools to use TLS 1.1 or TLS 1.2 .For example if you still want to use Java 7 and force your ANT tool to use TLS 1.1 ,you can add an environment variable like below for windows 









6.If you use Java 7, disable TLS 1.0. (TLS 1.0 is disabled by default in Java 8.) Update your eclipse.ini file to include this line:
 
Update your eclipse.ini file to include this line:
-Dhttps.protocols=TLSv1.1,TLSv1.2 
 
The location of the eclipse.ini file depends on your operating system. For more information, see [https://wiki.eclipse.org/Eclipse.ini].

Hopefully this sheds some light and those of you trying to fix this issue get enough out of it and fix your issues .

There is more info here below 

https://help.salesforce.com/apex/HTViewSolution?id=000221207


Feel free to ping me on twitter @msrivastav13 or reach by mail msrivastav13@gmail.com in case of concerns .



Tuesday 26 April 2016

Lightning Locker Service Salesforce

Summer 16 pre-release notes are out from salesforce and one of the most important featuresis Lightning Locker Service for Lightning Components.

Here is a very detailed article on how this feature  works under the hood .The article Highlights the key security features that this feature will enforce on the components.

The biggest benefit from an ISV perspective will be ability to scan the component before you submit your component for the security review.

Salesforce also released a CLI tool for all partners and app developers to run scan locally on the lightning component to discover potential security issues or unused variables and enforce security best practice and code best practice.

In this blog I am gone to detail step by step instructions on how to Install the Salesforce Lightning CLI and Scan your components before submitting for appexchange or handing off your lightning component code to your client.

Step 1 - Heroku Installation

Depending on your OS version one can install the Heroku  toolbelt on your machine .The URL for the download is below

https://toolbelt.heroku.com/

Step 2 - Login via Command Line 

Once you install ,you can use your Heroku credentials to login in .If you have not signed up for heroku ,you can sign up for one online 













Step 3 -Install the Lightning CLI Plugin.

This can be installed by running following command once you login into heroku CLI

heroku plugins:install salesforce-lightning-cli

Step 4 -Navigate to your project path where you have your lightning component project on your local drive.

If you are on windows simply CD into the project path with cd /.path




Step 4 - Run the CLI command to find Issues

heroku lightning:lint .







You can get rid of unused variables and resolve bunch of errors .

Read further on this in below link

https://developer.salesforce.com/docs/atlas.en-us.202.0.lightning.meta/lightning/cli_rules.htm#cli_rules

Lets not just stop here ,there is a nice little documentation put together where you can add your own customized rules 

Here is the link to the documentation

https://developer.salesforce.com/docs/atlas.en-us.202.0.lightning.meta/lightning/cli_rules_customization.htm

Please note that Salesforce Safe Harbour Statement applies to this post and you should not make any buying decision on forward looking statements and instead make purchasing based on current offerings of the platform .

Friday 8 April 2016

Finding Astro - Adventure and Mystery

Trailhead is an awesome platform to learn and explore Salesforce . Whether you are an admin,developer or consultant on Salesforce Platform ,Trailhead is a fun way to gain an understanding of the amazing platform .



One of the most exciting badges for this release has been WheresAstro module on Trailhead .Astro went missing on April 1st and you have time till April 14th to find it .




Key Motivator To Complete this Challenge

The key motivator to complete the challenge is you may be a lucky winner to win a fit bit or an Astro Doll . 



Journey and Exploration 

This modules requires your 30-40 minutes of time and its totally fun .You will start your journey by supporting the global search by changing your profile picture on the social media .


Don't worry there is already a nice heroku app running that will help you with background image .
Also you will discover some notes to download and read .

Start taking help of developer org to discover the mystery .You will learn how to create a simple developer org and use standard salesforce Accounts and contacts . You will enter all suspects using in contacts and your account is Trailhead .

Unlocking the clues

In this reading of 15 minutes you will learn how to use Geolocation fields .You will map all your suspects (AKA Contacts) on the google maps using location field . 




Follow the Trails

Use your dog and keep adding all those your dog finds to the contacts so that you can finally locate 


Cracking the Code

Finally this is where you need to be extra cautious and complete the mission .
So why wait ..Hurry up and head to the Trail and find missing astro and all along the journey learn how to use force.com and salesforce to manage your business

Don't forget to share your journey through your blogs or tweet your tweets using @Trailhead

Tuesday 29 March 2016

Taking your Lightning Components Outside Salesforce - Lightning Out

Lightning Out  is a powerful feature where you can take your components built inside SFDC to the external system .The Program is under BETA currently .

I have been building lightning components since last year and this year more than half of my time I have been working with lightning components .In fact this year in one of the community led conferences,SEDreamin in Atalanta ,I along with one my colleague architect at CodeScience INC got opportunity to present on lightning components .

If you are interested on slides ,we have the slides on the slideshare  and also the code on the github repo  .

So in this post ,we will take one of those lightning components to outside salesforce system .We will be pushing this components to heroku .The Heroku app build will be using Node JS .So this article assumes you have knowledge on NodeJS.

Libraries Used

1.nforce - This is a utility that provides ability to obtain access token via oauth (web server flow mechanism) 

2.A free Heroku account .You can install Heroku toolbelt depending on your operating system

3.We are using express and  ejs npm package .Using Express and EJS you can build node applications super fast with minimal effort .Ejs has an awesome templating mechanism with excellent support for javascript

Salesforce Configuration 

1.Create a simple Connected App 


 2.Create a CORS record for your heroku domain 


This is a security feature again and found in security controls

    










Lets take a look at the app.js file which triggers the flow

Here are the key highlight from the code 
  1.  We use the nforce library to request for the oauth token 
  2. We store the oauth token using app local variables so that we can retrieve this in our templates
Here is the code for Homepage of the app


The key points to look for

1.Observe how simple it is to write four lines of code to inject the lightning component into the page
2.The EJS template engine makes our life lot simpler to inject variables .

The entire code is in my github repo if you want to take a peek .  


Lets watch the video of the component running outside SFDC 




Lightning Out from Mohith Kumar Shrivastava on Vimeo.



Please let me know the feedback on this post via twitter or mail . Happy Hacking :)

Sunday 28 February 2016

Lightning Events Via Visualforce

This post is again as per request from one of my friend .He wanted me to put together a simple demonstration of how to handle lightning events from visualforce and how to publish or fire lightning events from outside salesforce .Both of these cases are extremely common if you are building application using lightning for visualforce .

If you have already started adopting Lightning component framework ,you probably know how important are Events .There are two types of events , Application events and Component Events .Please note that prerequisite for understanding this blog is understanding of events in context of lightning component framework .

The below code snippets apply to only application events .

Application events are handled by all components that are listening to the event. These events are essentially a traditional publish-subscribe model.


1. Firing Events from the Visualforce and Handling the Events in lightning components


To demonstrate this ,lets create a simple event file and fire the event from the visualforce inside the callback and handle the event back in the lightning component file

Below is the component set up for lightning framework

Lets put together the visualforce code needed for the experiment

Here are the exciting results











Now this opens a world of new opportunities to mash up already existing visualforce UI with lightning component framework.


One sample project that i experimented is in my git repo which takes map component as a lightning component but receives pickers from the visualforce select option .


2.Firing events from the lightning component and handling the event inside visualforce


This is another interesting observation ,you can fire an event from the lightning component and handle the event inside visualforce .

Lets see the hello world code for this scenario

The visualforce code is as below

Fun part




I hope this opens up a whole world of new directions to design and build some excellent mashups with visualforce and lightning .

Please reach out via my twitter @msrivastav13 or mail msrivastav13@gmail.com.

Introducing Lightning Base Components

Lightning Base Components are great addition to the platform and in fact revolutionary .One of the concerns around lightning component ...