Tuesday 2 August 2016

Grow Your Business by Auto Geocoding your Leads or Customers

Any marker you see on Map is always represented by 2 things i.e. Latitude and Longitude. Till Summer'16 it has been a challenge to geocode Salesforce addresses automatically so that they are ready to plot. Many have used third party APIs and Scheduled Batches to process Account/Contact/Lead records but trust me that was all time eating your API limits.

So, what is the surprise! Salesforce have released a feature in Summer'16 by which your Account/Contact/Lead records can be auto geocoded. This feature uses Data.com in back end but you don't need Data.com license for activation of auto geocoding feature. You just need to setup cleaning rules and you are good to go. So, precisely following standard Address fields can be auto geocoded based on any changes to below address fields.
  1. Billing Address on Account
  2. Shipping Address on Account
  3. Mailing Address on Contact
  4. Address on Lead
Yes, on key thing to note "Person accounts are not supported at this point!"

For learning "How to setup cleaning rules" kindly read and follow below link:
Set Up Geocode Clean Rules

Which fields store Lat/Lon pair in each of the objects above:

  • Account Billing Address Geocode Fields: BillingLatitude, BillingLongitude and BillingGeocodeAccuracy
  • Account Shipping Address Geocode Fields: ShippingLatitude, ShippingLongitude and ShippingGeocodeAccuracy
  • Contact Mailing Address Geocode Fields: MailingLatitude, MailingLongitude and MailingGeocodeAccuracy
  • Lead Address Geocode Fields: Latitude, Longitude and GeocodeAccuracy

What happens when Geocoding happens:

  • Respective Latitude and Longitude fields are overwritten.
  • SystemModStamp field is always updated. You need to review integrations which use this fields as criteria for qualification of records to get processed.
  • By default, LastModifiedDate and LastModifiedById fields are not updated. You can change this behavior when you set up your geocode clean rules.

How to use this feature for business:

  • You can use this to plot all your leads to understand how is the flow of inquiries per territory
  • You can visualize your customer base on map territory wise
  • You can start new campaigns to build your brand in new territories where you don't see much of your existence
  • This can also be useful for plotting customers for Sales Reps/Marketing Reps
  • Field Service can be another application of same


Sample code to try:

 public class PlotLeads {  
       
     public List<Leads> lLeads {get; set;}  
     private String unitOfMeasure = 'mi';  
       
     public PlotLeads() {  
         //Fetching all Leads in 20 miles radius from my company HQ  
         lLeads = [SELECT Id, FirstName, LastName, Latitude, Longitude   
               FROM Lead   
                 WHERE DISTANCE(Address, GEOLOCATION(35.273,-115.130), :unitOfMeasure) < 20  
                 ORDER BY DISTANCE(Address, GEOLOCATION(35.273,-115.130), :unitOfMeasure)];  
     }  
 }  

Thursday 12 May 2016

TRAILHEADX - Salesforce Developer Conference

Trailhead has been one of the most successful gamified learning platforms for Salesforce aspirants. Trailhead has become the key to success for many big organizations as well as SMBs to train new comers. It also helped many graduates, veterans, students to get jobs and be successful in their careers. Trailhead has been my first choice when I guide engineering graduates in many engineering colleges to transform their careers in Salesforce.com technologies. It is THE BEST and it will be THE BEST! After huge success of Trailhead; Salesforce has launched first of it's kind a developer conference "TRAILHEADX" specially for Salesforce developers. If you attend "TRAILHEADX" then you will be inspired by some of the top technologists and visionary leaders in the industry.

This time it is happening on "7th and 8th June 2016" at "The Village & The Warfield, San Francisco, CA". Salesforce have 2 types of passes for this conference i.e. Full Conference and Free Keynote Pass. Full Conference passes have been sold out but you can still get Free Keynote Pass.

Don't worry; Free Keynote Pass also have lots of good stuffs:
  • You can watch keynote presentations by Marc Benioff, Parker Harris and Shawna Wolverton
  • You can enjoy Salesforce App Cloud and Lightning in action with cutting edge technical demos
  • Join a fireside chat with Steve Wozniak (Co-founder of Apple)

For Registering your Free Conference Pass: https://developer.salesforce.com/trailheadx

Last but not the least; Salesforce also have lots of prizes and a epic party organized for you!

Regards,
Sumitkumar Shingavi (9x Salesforce.com Certified)
Linkedin: https://in.linkedin.com/in/sumitshingavi
Email: sumi.shingavi@gmail.com

Tuesday 23 February 2016

More about Navigate the Salesforce Advantage : A TRAILHEAD TRAIL

This trail on trailhead is intended for audience who want to adopt or start learning Salesforce.com. Salesforce is very dominant player in Cloud ecosystem and it is very critical for Customers, Admins, Developers and Business Users to understand what Salesforce can do for them. Why Salesforce is mentioned as "Customer Success Platform"? How powerful it is as platform and CRM? And ways Salesforce can help businesses to perform better. This trail can answer all those questions!!

This trail has 4 primary modules:
1. Salesforce Success Model: This module gives high level zest of What is Salesforce? Salesforce is multi-tenant cloud platform and CRM. Salesforce supports both B2B and B2C business models. Salesforce helps you build more meaningful relationships with your customers; to better understand their wants and needs, identify new opportunities to help, and address their problems faster. The key to this success is having one connected platform to manage all of this. It is critical to understand the capabilities of Salesforce as CRM and platform so that to take right decision for selecting right cloud platform for your needs. So, in high level this module teaches who Salesforce is and their vision for driving customer success. Finally, Salesforce as company is totally focused on Innovation and Customer Success all the time by leveraging great leadership and giving back attitude i.e. Corporate Social Responsibility.



2. Salesforce Cloud Benefits: This module explains about what you get from Salesforce when you choose to go with it? Salesforce is multi-tenant high performance cloud platform and Salesforce is trying reach all possibilities in cloud to have everything at one place. Adopting Salesforce is very easy game as customers can achieve lot of their business processes just by using Out of the Box (OOTB) features and AppExchange products. For doing custom developments; Force.com is the BEST platform in whole cloud ecosystem. This module also helps to understand how to propel your business with the adoption of Cloud. So, in high level this module teaches the flexibility of a "complete" CRM that evolves with customer business needs. Salesforce is very "Agile" platform. Finally here is very good distinction about on-premise and cloud so that you understand why to go with Cloud.



3. Salesforce Technology Basics: This module talks about why Salesforce is trusted cloud platform? and The beauty of Multi-tenancy in Salesforce core technical stack. That means every customer shares same baseline infrastructure and code base. This module also explains the way Salesforce drives the customer customization and configurations using metadata and provides easy accessibility of the metadata layer, the cloud, and Software as a Service (SaaS). Also, customers can develop custom apps very rapidly and go to market time is very low [This is totally based on complexity of application but usually customer should start with Must Have then good to have and then fancy stuff around]. So, in high level this module gives a peek under the hood of Salesforce's core technology model based on trust and innovation.

4. Salesforce Ecosystem: This module talks more about awesomeness of Salesforce's incredible partner ecosystem and customer community. All the documentation is very precise. Customers can also use Success Community for technical questions and asking for best practices, etc. Salesforce periodically organizes lot of events around the world. I love to be part of Pune Salesforce Developer User Group. There is always lot of knowledge sharing and off course goodies :D Salesforce swags are always lovely!! Finally attending Dreamforce will also help a lot if you want to understand width and depth of Salesforce technologies.

Wait..Above all is about Salesforce!! But if you are looking for more technical comparison of multiple CRMs; here is the high level table:


There are lot other CRM players exist in the market in addition to Salesforce and MS Dynamics CRM like ZOHO, GoldMine etc.

Brief about ZOHOCRM: ZohoCRM is a relative newcomer to the CRM marketplace and good fit for small businesses. ZohoCRM is just one of a suite of business applications from Zoho that include productivity, office, project management, invoicing and recruiting. The Enterprise version of ZohoCRM runs $35/month/user but a free, stripped down version is available for less than three users. ZohoCRM is completely cloud based, integrates with many Google Apps and syncs with QuickBooks and Outlook. There is also a growing army of Zoho developers and partners with tools to further customize and integrate the product with other systems.

Brief about GoldMine: GoldMine is on-premise and more of an advanced contact manager than a full blown customer relationship management system. But the aging product has been around for many years and still maintains a large following. GoldMine is good for organizations with 5-25 users and costs about $3,000 for a five concurrent user system. It is quick to setup, easy to use, synchronizes with Outlook and QuickBooks and sold through a national network of resellers and partners.

Finally, if you want to adopt Salesforce then you MUST should use Trailhead.
Here is the link to trailhead: https://developer.salesforce.com/trailhead?state=id

Salesforce is the BEST CRM and Cloud Platform!!!


Here is my Trailhead profile: 
https://developer.salesforce.com/forums/ForumsTrailheadProfile?userId=005F000000431sYIAQ

Regards,
Sumitkumar Shingavi
Linkedin: https://in.linkedin.com/in/sumitshingavi
Email: sumi.shingavi@gmail.com

Friday 17 April 2015

Writing Apex Scheduled Batch class - Framework!

Basics:
1. Apex schedulers are implemented to do data/logical processing at a given time.

2. Apex batch classes are implemented to process LDV (Large Data Volume) for given objects.

3. For implementing a schedule class you need to implement "Schedulable" interface

4. For implementing a batch class you need to implement "Database.Batchable" interface

5. You can make a single class both Schedulable and Batchable so you don't need to have 2 separate class for batch and schedule. Kindly see below code for this.

6. Standard batch size is 200 and it can be modified/changed when you invoke Database.executeBatch method to call batch class. (second parameter of this method is batchsize where first param is instance of class). Maximum value of size can be 2000 and minimum should be greater than ZERO.

7. Apex batch processing is "Asynchronous" mechanism so no guarantee on time of processing

8. When you schedule something at 7am for example, it is not guranteed that it will execute at same time. Your job actually pushed to Salesforce queue for same at 7am and Salesforce will pick it up based on resources available on Salesforce Cloud (Servers). So in nutshell, actual execution might be delayed based on service availability.

9. You can only have 100 scheduled Apex jobs at one time. You can evaluate your current count by viewing the Scheduled Jobs page in Salesforce and creating a custom view with a type filter equal to “Scheduled Apex”. You can also programmatically query the CronTrigger and CronJobDetail objects to get the count of Apex scheduled jobs.

10. When implementing test class for your scheduled batch class, you should have all assertions after Test.stopTest() as this is an asynchronous processing.

11. Governor limits for batch and scheduled apex applied separately. So, all scheduled apex limits apply for batch jobs scheduled using System.scheduleBatch. After the batch job is queued (with a status of "Holding" or "Queued"), all batch job limits apply and the job no longer counts toward scheduled apex limits.

Let's get on code! If you want to process Account records by a scheduled batch..

How your code framework should be for AccountBatch?


Some important considerations:
1. Your batch size ideally should fall under 50-100 but there is no standard rule for this. Batch size is really defined based on how many DML statements on different objects you have or how many callouts your are doing from your method?
2. The start(), execute(), and finish() methods can implement up to 10 webservice callouts each. Time for each callout is 120 seconds. (Documentation Link: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htm)

But this limit is "100" now. You can make 100 callouts from a batch.

Serial Batch processing:
This is very common scenario where you need to execute batch classes on different object right one after the other. How can you achieve that? It is very simple; you can call next batch in finish() method of your current batch as finish method is actually for doing something after work done is committed by your batch.

What is Database.Stateful?
This is an interface used to maintainsstate across transactions. When using Database.Stateful, only instance member variables retain their values between transactions. Static member variables don’t and are reset between transactions. If you don’t specify Database.Stateful, all static and instance member variables are set back to their original values.

What is Apex Flex Queue?
It is used to submit up to 100 batch jobs without getting an error. The batch job is placed in the Apex flex queue, and its status is set to "Holding". This feature is released in Spring'15 and it is great improvement over Apex batch queue. 

Writing Apex Triggers - One trigger per object - Framework!

Apex triggers are one of the most essential part of Force.com platform for back end automation. Apex trigger code is always executed before or after the events insert, update, delete, undelete, merge (update + delete), upsert (update + insert)

When to use before triggers?
When you have a requirement to update the record on same object on which trigger is implemented. Before triggers are also implemented when there is any kind of custom validations to be done based on set of fields (compound key) or a field to show a custom message (addError).

When to use after triggers?
When you have a requirement to create/update/delete operation on other object than the object on which trigger is implemented. i.e. Create a Warranty__c record after opportunity is "Closed Won"

Very important rule to keep in mind while implementing triggers is "Only ONE trigger per Object"

3 ways to write Apex Triggers:

  1. Modular Programming Approach – Simplest
    • We use this 70% of times
  2. Factory Pattern (20%)
  3. Abstraction of Handlers (10%)
    • When there are multiple handlers for a object 
    • Sequencing of handlers is required in execution
    • Dynamic instance creation is required.
    • CustomSettings__c cs = CustomSettings__c.getInstance('Vehicle'); 
    • Type t = Type.forName(cs.className__c);
    • Vehicle v = (Vehicle) t.newInstance(); 


Standard batch size of any bulkified trigger is 200. But if required then you can split it in code as n < 200 batch size. So, let's get started with a robust, easy to control and easy to maintain framework for a trigger on Account object!

How my AccountTrigger code will look like?

How my AccountTriggerHandler code will be?

How my AccountTriggerActions code will be?

How my AccountTriggerTest code will be?

Some technical specifications about above code:
1. Trigger_Control__c : This is a Hierarchical custom setting object which is used to control the execution of Account trigger. At this moment, I am looking at OrgDefaults but you can code it to look at a specific profile/users custom settings. This is very useful when you are working on an enterprise scale project and want to migrate millions of records without keeping these triggers on (Historic Data migration). You can have a user like "API Connect" and configure Trigger_Control__c for him on those trigger fields like Account_Trigger__c by marking it false. Once done, you can turn this field on again!

2. Naming convention: Naming conventions I followed in above code are usually best way I found so far. It helps to see all components in one shot listed under each other and also variable naming convention helps not to keep all variables in mind while coding.


Advantages of above framework:
1. Precise control on order of execution inside a singleton trigger
2. Separation of concerns
3. Control over re-entrant code
4. Clear organization and structure

What happens when upsert / merge event occurs?
1. Upsert: Upsert triggers fire both before and after insert or before and after update triggers as appropriate.
2. Merge: Merge triggers fire both before and after Delete triggers for the losing records and Before update triggers for the winning record only.


Thursday 19 March 2015

Salesforce Trailhead - A way to learn Salesforce.com technologies throughly!

After completing all existing Trailhead modules and receiving all badges; I thought to write this article for promotion of Trailhead! Trailhead is a truly amazing way to learn Salesforce.com technologies. The way Trailhead is structured and the modules are formed is phenomenal!

I feel, this is Salesforce.com's incredible effort to make developers life easier to learn Salesforce.com technologies and do an easy adoption. Below is the snapshot of my Trailhead profile and you can see, I own all 16 badges currently exist on Trailhead!



Here is the link to Trailheadhttps://developer.salesforce.com/trailhead

You can simply login with your developer org. credentials and start completing modules.

In this post I decided to summaries all modules in brief so that devs can jump on any module and finish it up. Let's have a look at every module one by one:

1. Apex Basics & Database: This module will teach you how to use Apex to add business logic and manipulate your Force.com data. It has got sub modules covering topics like Apex, SOQL, SOSL, DML, etc.

2. Apex Testing: This module will teach you how to write robust code by executing Apex unit tests. This module contains sub modules for how to create  test data and test triggers / apex classes.

3. Apex TriggersThis module will teach you how to write Apex triggers to perform custom database actions. 

4. Change Management: This module will teach you how to safely deploy changes by developing them like apps. This module has sub modules for governance management and change set deployment, etc.

5. Process Automation: This module teaches you techniques to do process automation using point and click features of Salesforce which will save lot of time across your organization to automate repetitive business processes.

6. Chatter Basics: This module helps to learn how to develop a Chatter rollout strategy and help your users get started with enterprise social collaboration. 

7. UI Customization: This module will teach how to modify out of the box UI components like Page Layout and List Views to customize your app's user interface without code.

8. Data Management: This module will teach you how to import and export data in Force.com.

9. Data Modeling: This module is very important and will teach you how to implement your data structure with objects, fields, and relationships. This covers Standard objects, custom objects & fields, Lookup and master detail relationship, schema builder tool.

10. Data Security: Very important and useful module to configure the control access to data using point-and-click security tools.

11. Lightning Components: This is most hottest model to learn new Lightning framework from Salesforce. This is usually used to build modern apps faster with reusable UI components and extends Aura framework. 

12. Formulas & Validations: This module will teach you on how to tailor your apps without writing code by using point-and-click logic. 

13. Salesforce1 Mobile Basics: This module will teach some quick tricks for customizing your mobile experience with Salesforce1. 

14. Force.com Basics: This module is core of all which give you first intro to Force.com and learn your way around the platform.
Link: https://developer.salesforce.com/trailhead/starting_force_com/starting_intro

15. Visualforce Basics: Want to build customized UI? Here you go! this module will teach you how to use Visualforce to build custom user interfaces for mobile and web apps.

16. Visualforce Mobile: Want to develop custom UI/UX for mobile apps which access your Salesforce data? Then this is right module to start on! This module teaches you how to use Visualforce to customize and expand your Salesforce1 mobile experience. 

Hope this helps your to decide where you want to start!

Happy Learning!

For any queries, write on sumi.shingavi@gmail.com
Follow on Twitter at @sumit_shingavi

Monday 9 February 2015

What is Salesforce Mobile SDK 3.1 & Why to use it?


Quick characteristics of Salesforce Mobile SDK 3.1: 
  1. It is unified app architecture (SmartSync API for fast and responsive apps) brings unparalleled flexibility meaning that you can built hybrid or native apps using same core set of functionality regardless of their target platform. 
  2. Salesforce Mobile SDK 3.1 does have everything consistent like all the libraries, all the APIs & all the major mobile building blocks.
  3. Extended choice of development tools or UI frameworks like for iOS you can now use CocoaPods. So, with the Salesforce Mobile SDK 3.1 release, mobile developers no longer have to make these trade offs for selecting a preferred technology.
  4. Salesforce Mobile SDK 3.1 have flows to initiate authentication with an enterprise certificate.
Something Developers need to keep in mind!
  1. iOS 7 is now the minimum OS version for developing your iOS apps on the top of Salesforce Mobile SDK 3.1.
  2. For Android, min version required is 4.2.2 - API_17
Unified SmartSync APIs : This gives "Bulk Sync Routines Executive" from the native layer, even in hybrid apps with a new SmartSyncPlugin for Cordova apps. It also helps for full CRUD operations for online and offline usage.

CocoaPods for iOSDevelopers now have the ability to consume the Salesforce Mobile SDK through CocoaPods, which makes dependency management a chore of the past. It’s now easier than ever before to insert Salesforce Mobile SDK modules into an existing app or evolve a new app with other third party libraries.

Gradle for Native Android AppsAndroid Studio and the Gradle build system are now fully supported for native apps.  Gradle support for hybrid apps will arrive after the next Cordova update.

Certificate Based Authentication PilotLeverage certificates as part of an enhanced authentication flow without asking your users to enter a username and password.