Testing Strategies for Developer
Jun12

Testing Strategies for Developer

Salesforce provides a framework for testing apex code. Testing is the key to successful software development. Before deploying apex code, try to cover as many lines of code as you can. At least 75% of your Apex code must be covered by unit tests else your code will not be deployed to production. Why Test? You should not write test classes by keeping in my mind just to cover 75% of your code but should always try to cover your entire code before deploying to production. Test provides assurance of functionality Test reduce cost of change Test encourage modular and reusable code Test help document expected behavior Test + Code = less likely produce the bug What to Test? Things that should happen to happen (Positive) : Positive testing is a way to test expected behaviour of code that you wrote is suppose to do. Things that should not happen to happen (Negative) : This is the hardest and important thing to test that verify if the error messages are correctly produced along with the positive working of test cases, within the limits cases. User Access : This is basically the manual testing, which we perform by seeing the aspect of end-user test is done when we think of user interaction. This type of test is done by hand via insert, update, delete and undelete the records. Exceptions : Exception testing tests expected behaviour of code when an user with restricted access to sObjects are used in code. Bulk Testing : This test comes in when a class, trigger or any apex code insert and update data in bulk. We need to test the class by creating more than one record in multiple scenarios. Test Structure Principles for Best Practices Principle #1  Use of Asserts : Assert is the method of System Class. It is an important method for test class which is used to check the expected result of test scenario. “A test without assert method isn’t a test, it’s code execution.” There are three in-built assert methods which are as follows: assert(condition, message) assertEquals(expected, actual, message) assertNotEquals(expected, actual, message) Every test method should include at least one assertion. Principle #2   Use startTest() and stopTest() startTest() methods are used to reset governor limits. The code between Test.startTest and Test.stopTest executes in fresh set of governor limits that means your setup code will not interfere and give you false positives (or negatives) surrounding governor limits. stopTest() method focuses on asynchronous code to complete. In general, one should follow these steps while writing test class: Create your test data Start the test Use that test data within your tested...

Read More
Data Loader VS Batch Apex
May25

Data Loader VS Batch Apex

Data, data, and loads of data!! Would you still prefer to migrate this lot of huge data in the old traditional way by creating the number of excel sheets, matching it, again and again, to avoid any errors, giving strain to your eyes and wasting much of your time? Let’s suppose somehow you managed to import million of records and then end up with inserting few wrong values. Alas, now for sure you have to do it all over again. If we are living in a high-tech world then why would you want to do things manually when it can be done programmatically. Yup, we can insert a lot of data using just a Batch Apex. Though both Data Loader and Batch Apex has its own advantage in their own ways but you have to be judgemental to use it wisely. Let’s throw some light on both of these. DATA LOADER- What’s this??? Before we waste any time, let’s first understand what Data Loader is. Simple but yet powerful, it’s a Desktop tool to migrate data from two IT systems. It generally focuses more on migrating data in between two different environments. Consider an example where you want to migrate a .csv file from your old legacy system to Salesforce cloud-based system, this can easily be done via Data Loader. Other Use Case Scenario: Want to have a daily backup of your customer records. Importing records of emails that you want to update for lead comparison. Importing a report file that is been generated in third party marketing automation tool that you want to link with Salesforce accounts. How It Function?? When you import data, Data Loader first reads it, then extracts it and lastly loads data from CSV files or database connections. See operations below:     DATA LOADER- Advantage Data loader has too many advantages in its own way: The first and the foremost advantage is its automation process for complete data migration & yes! it’s hassle free. It helps you insert, export, update and delete data. One can perform DML Operations on up to 5 million records. It is an easy-to-use GUI-based interface. Drag and drop field mapping is one of its features. Detailed files showing success and error messages make it more easy to use. It supports Windows or Mac. BATCH APEX- What’s this??? Large sets of data is not a piece of cake for Data Loader in any way, It’s when Batch Apex comes into the scene. It generally focuses on processing bulk data within SFDC. It is easy to use with large volume set of data for migration. What one needs to do is...

Read More
Salesforce Web Service Testing Tool
May06

Salesforce Web Service Testing Tool

WEB SERVICES Web service or API is a collection of procedures or software components that help an application to interact or perform some process/transaction by forming a connection between other application or server. There are basically two types of web service – REST and SOAP to drive the communication of data and information over internet protocol. Two specifications for Web Services are illustrated in this section: SOAP, REST SOAP SOAP was originally part of the specification that included the Web Services Description Language (WSDL) and Universal Description, Discovery, and Integration (UDDI).It is an XML-based protocol for accessing web services. SOAP defines a standard communication protocol (set of rules) specification for XML-based message exchange. SOAP uses different transport protocols, such as HTTP and SMTP. The standard protocol HTTP makes it easier for SOAP model to tunnel across firewalls and proxies without any modifications to the SOAP protocol. SOAP can sometimes be slower than middleware technologies like CORBA or ICE due to its verbose XML format. SOAP messages are hard-coded or generated without the use of a repository. The interaction is illustrated in the figure below.   Representation State Transfer (REST) Representation State Transfer (REST) appeals to developers because it has a simpler style that makes it easier to use than SOAP. It also less verbose so that less volume is sent when communicating. REST web service permits different data format such as Plain Text, HTML, XML, and JSON. REST describes a set of architectural principles by which data can be transmitted over a standardized interface (such as HTTP). REST does not contain an additional messaging layer and focuses on design rules for creating stateless services. A client can access the resource using the unique URI and a representation of the resource is returned. With each new resource representation, the client is said to transfer state. While accessing RESTful resources with HTTP protocol, the URL of the resource serves as the resource identifier and GET, PUT, DELETE, POST and HEAD are the standard HTTP operations to be performed on that resource. The interaction is illustrated in the figure below. Web Services Testing Tool Salesforce supports the following  type of testing tools: Workbench POSTMAN APIGEE In this blog, I will let you know about how we can use POSTMAN testing tool. Before getting started with the postman, we need to keep following in mind: We should have a Class that will process the request and generates the response as per it. We need to have Connected App which will provide you the Consumer key and Consumer secret that will be used later for authentication. Lastly, the valid username and password with the...

Read More
Salesforce App Builder Certification
Mar14

Salesforce App Builder Certification

The Salesforce Certified Platform App Builder exam is for them who want to grow in their skills and knowledge in designing, building, and also want to implement custom applications using the predeclared customization capabilities of the Force.com platform.   In June 2015, Salesforce University introduced the three new certifications: Salesforce Platform App Builder Platform Developer I Platform Developer II Salesforce University splitting the Developer track into declarative certification and two programmatic certifications. The Salesforce Platform App Builder certification is like to the Certified Force.com Developer credential. Here are some concepts for understanding to pass the exam: Design the Data model, user interface, business logic and security for custom applications Customize applications for mobile use Design reports and dashboards Deploy custom applications The Platform App Builder Exam is an only 90-minute exam. The exam contains  60 single or multi-select questions. The passing score is 63%, or 38 correctly answered questions. How to prepare for the Salesforce Platform App Builder Certification Exam   Review the concepts in the Platform App Builder Study Guide & Group Objectives by Their Weightings as given below:   Perform a Self Assessment on the objectives and ID Areas Needing Knowledge Improvement Increase Your Knowledge Building Applications with Force.com Part 1 Building Applications with Force.com Part 2 Grab a Personal Developer Org and Practice Those Concepts Familiarize yourself Mock Questions Daily Routine: Take Mock Exams and Study Notes   Tips The App Builder Exam is very broad but it does not go extreme depth, So you will need to have an overview of a lot Salesforce & Force.coms features. Make sure that go through each section in the study guide and revise accordingly. The social section is worth 3% of the exam so you can only expect 1 or 2 questions. Make sure that read other guides as well, each person has a different take on the exam and may provide different insights. The process of elimination is yours! If you can not work out which answer is right, try and work out which answer is wrong! To get more information about Platform Developer I. Click here ...

Read More
SKUID-Scalable Kit for User Interface Development
Jan10

SKUID-Scalable Kit for User Interface Development

SKUID SKUID has always been my favourite since the first time I saw this in Dreamforce 2014. My first interaction was with their team on Dreamforce booth and the after understanding its capabilites I was amazed! SKUID is set of tools that allow you to change almost any element of your Salesforce User Interface, quickly and easily. We can quickly implement any changes as per suggested by your team, across your org and even in Production. It is basically used to build the UI to have a look on the data your company needs. STORY: Salesforce connected Rich (Rich Slack, CFMO of Chrysalis and CEO of Meridian Meds) with a private developer who would charge $300,000 – $500,000 to build out their user interface. It was a non-starter. Rich decided to kill the Salesforce project and hire a team of developers to create their own platform. However, the team hit many roadblocks. Rich realized that Salesforce could do what he needed if he could figure out a way to overcome the gap of user interface. That’s when he found Skuid. Within 2 days, Rich had re-skinned the user interface of his app within Salesforce. He rebuilt his entire system during his nights and weekends in four months.  Let’s get Started with SKUID: Compose your new page from Skuid Central tab in your Salesforce Org Connect your Salesforce objects and external data through models present in Skuid. For each MODEL, choose the standard and custom fields from your Salesforce objects that you want to include in your page, and can even set criteria for the records to get display on your page. You can create as many model as needed. The only thing to know is that they will be loaded the way they are listed. For each model we have: Fields: Fields refer to the fields from the object which we want to show in our page. Conditions: They apply criteria for the records which are to be shown onto the page. Actions: They help us to specify the actions which we want our page to perform after some event. We have two properties for Model which are Basic & Advanced. Basic properties let you define the model Id, data source type, SObject name, model behaviour, number of pages to be displayed etc. Advance properties let you have a look on cloning the data, Query Deleted, Update Salesforce Recently Viewed Info etc. Skuid provides you with pre-built components which can be used to create your own page. Also you can create your own components. There is only the need to drag and drop those pre-built components and you can...

Read More
5 things about Salesforce Certification
Jan03

5 things about Salesforce Certification

This blog is for the Developers who wants to get a Salesforce Developer I Certification . What is Salesforce Certification? Why is it so important for the developers seeking a career in Salesforce? Salesforce certification is vital to the salesforce career path as it differentiates you from other developers, makes you an expert in your field. This Certificate is provided by salesforce.com where people demonstrate and prove their technical Skills in different  areas of Salesforce. It’s a damn good certification, if you are thinking about a career in Salesforce, by enhancing your skills and expertise in respective fields. It is very easy to get hired in an organization with  a salesforce certification in hand. You need to follow these steps  to enroll  for examination : First you have to create your webassessor Account on             https://www.webassessor.com/wa.do?page=createAccount branding=SALESFORCE Secondly Register and schedule your exam Five  things you must know while preparing for salesforce certification:-  Course Content  and their  weightage -: The Salesforce Certified Platform Developer I exam measures a candidate’s knowledge and skills related to the objectives listed below. A candidate should have hands-on experience of developing custom applications on the Force.com platform and have demonstrated the application of each of the features/functions below. 2. Prepare each topic with written practice of programs. Exploring it on trailhead will be a  great start. It will provide huge knowledge for practical implementation. In different areas. Below is the  link to access trailhead: https://trailhead.salesforce.com/ 3. Go through /Solve previous years certification:- Preparing from previous year question papers is always a good strategy to cover frequently asked topics in a short span of time.  4. Practice as many Mock test papers as possible once you think you have a good command on Salesforce syllabus. Mock test papers are available on various websites for free where you can practice them. Do register yourself  if required (as asked by some of the websites)  5. And last but not least, be confident and relaxed while writing the exam and remember the best way to gain confidence is to do more and more practice. According to my exam experience every aspirant must prepare well in the following topics as most of the questions I faced in the exam were from these topics : Validation Rule Workflow Rule Process Builder Object Relationships So all the best guys for exam. The exam is simple and easy. All you need is to do...

Read More
Gravity Forms and Salesforce Integrations
Dec12

Gravity Forms and Salesforce Integrations

Gravity forms are generally the WordPress plugins to create a contact form. It allows site owners to create and gather the information. GRAVITY FORMS + SALESFORCE It forms a great combination to gather the information and add leads to Salesforce automatically. It helps making CRM more easy and simple. To set up it takes few minutes and provide you a way to collect information with much simplicity.  Gravity forms are much more interactive and provides you with easy way to add fields, making them mandatory, email etc. If you already don’t have this plugin installed then get it and make your work much easier. WEB FORMS to SALESFORCE We have several apps which does somthing similar on the context of getting your data drom a Web Form into Salesforce. Ex:- Web2Anything:- http://developer.force.com/codeshare/projectpage?id=a0630000003JS9MAAW formyoula:- https://formyoula.squarespace.com/ Salesforce.com Sites Pages:- You will have to custom build the vfpage with form and make it a publicly accessible URL. INTEGRATION To integrate your Gravity Forms with Salesforce follow the steps below: Go to setup in your Salesforce Org. and type web-to-lead in Quick Find box.                Generate new form. The redirect URL should be the URL where you want your page to be redirected after the submission of the form.   Select the fields you require in your Gravity Form and save the HTML code generated through it.               SYNC YOUR WEB-TO-LEAD FORM WITH GRAVITY FORMS Create your web-to-lead form as described above Look for the Salesforce Add-on tab(Form<Settings) and select Integration Method as Web-to-Lead. Update Settings.   Create your Gravity Form in your WordPress Site.                Add the fields you used while creating your web-to-lead form Save the form. Click the Gravity Form’s name and lookup for the confirmation tab under the settings. Select confirmation tab to redirect Redirect URL should be the URL you got while generating the web-to-lead form.     The URL should not include the “?encoding=UTF-8” since Gravity form do it itself on start of the query string. Check “Pass Field Data Via Query String” Your screen should look like this:       NOTE:  If you are trying to work in your sandbox then do change the Redirect URL to test.salesforce.com instead of www.salesforce.com since web-to-lead form generates form working in Production. Remember you removed “?encoding=UTF-8” from the redirect URL, now make this the first line of your Query String. Start with your oid and retURL to process our Query string. Each value should use “&” in between.   Now it’s time to map your salesforce fields to that of the gravity form you created. Build your query string in the following format:                field_name=field_value&2nd_field_name=2nd_field_value You can take help from...

Read More
Wave Dashboards in Lightning Pages
Nov25

Wave Dashboards in Lightning Pages

A Wave Dashboard is a collection of widgets that work together to tell a data story from multiple angles. Depending on what you want the dashboard to show or how to behave, you can add different widgets, such as key performance indicators, charts, tables, filters, and images.Embedding Wave Analytics Dashboard component to a Lightning homepage or record page can provide interactive visualization of your data. It is currently available in Lightning experience only. It offers additional features to help you build Dashboards more quickly and easily. Use a template to create a Dashboard with a predefined layout. Create customized layouts to optimize the display of a Dashboard on different types of devices, like mobile phones, tablets, and desktops. Use the wizards to quickly build widgets. Use drag-and-drop, snap-to-grid, and browser reflow to effortlessly add, position, and align widgets in a Dashboard. To add a Dashboard to your Lightning Page follow the steps below:   Select Wave Dashboard Component in the Lightning App Builder From the Dashboard drop-down list, select the Dashboard to display From the layout drop-down list, select the type of screen where your Lightning page will be viewed Configure following attributes of the Wave Analytics Dashboard:  Show Sharing Icon option lets you include Share icon on the Dashboard. If the icon is present, users can click to open the Share dialog, where they can post to Chatter and download images and data Show Title checkbox gives you control over the visibility of the Dashboard title Open Links in New Windows attribute, you can specify where links from the Dashboards to other assets are opened Hide On Error checkbox gives you control over whether the Wave Analytics Dashboard appears if there is an error Filter attribute, you can use JSON to filter dataset fields at run...

Read More
Salesforce Ant Migration
Sep20

Salesforce Ant Migration

Ant Migration tool is used to Create and Fetch Metadata to and from an organisation.  It’s a  command-line utility by which one can upload and download Metadata components. Benefits Its very useful for creating repetitive deployment or may be a large number of components just by executing a command in an command line interface. Useful for uploading test environment with a lot of configuration settings. Manually creating Fields, Objects may take a huge amount of time when you create them by clicking with the salesforce interface. These fields can be created with one command in the Command line interface and using Package.xml file in which you specify the information about all the fields. The Name of the components we can Deploy or retrieve are as follows: Custom Fields. Objects. Workflow rules. Apex Triggers. Apex Class. Visualforce Pages. Etc. The Whole list is mentioned in this link: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_types_list.htm   Installation Download Force.com migration tool from your salesforce organisation. Go to Setup. Type “Tool” and Click on Force.com Migration tool & Toolkits. Go to the Following Link for downloading Ant: https://gs0.salesforce.com/dwnld/SfdcAnt/salesforce_ant_36.0.zip Add the bin directory to your path. Set the ANT_HOME environment variable to the directory where you installed Ant. Set the JAVA_HOME environment variable to the directory where the JDK is installed. Run command in Command line Interface:   “ant -version” to check the version and confirm the installation. Usage Create three Files: Package.xml – Which consists the specifications for the components. Package.xml <?xml version=”1.0″ encoding=”UTF-8″?> <Package xmlns=”http://soap.sforce.com/2006/04/metadata”>    <types>        <members>*</members>        <name>CustomObject</name>    </types>    <version>37.0</version> </Package> Build.properties – Which consists the Credentials of the salesforce Organisation to & from which you want to Upload/Download. Build.properties sf.usernameDownload = Sf.User@Name.com sf.passwordDownload = Password122   sf.usernameUpload = Sf.User@Name.com sf.passwordUpload = aasfde@12131QV4cWJnmdflgBRdXsWznzohG sf.serverurlDownload = https://login.salesforce.com sf.serverurlUpload = https://login.salesforce.com sf.maxPoll = 100 Note: You have to mention Security token at the end of the password of the Org in which you want to Upload the metadata.   Build.xml – This file is used to set the attributes which will be used in the Command line interface such as “Project Name”,”Property File”,”retrieveTarget folder( where Downloaded metadata info will be saved)”,”unpackaged(Package.xml file)”. Build.xml <project name=”ANT Migration” default=”test” basedir=”.” xmlns:sf=”antlib:com.salesforce”>   <property file=”build.properties” /> <property environment=”env” /> <target name=”retrieve”> <mkdir dir=”Retrieve” /> <sf:retrieve username=”${sf.usernameDownload}” password=”${sf.passwordDownload}” serverurl=”${sf.serverurlDownload}” retrieveTarget=”Retrieve” unpackaged=”unpackaged/package.xml” pollWaitMillis=”10000″ maxPoll=”100″ /> </target> <target name=”upload”> <sf:deploy purgeOnDelete=”true” username=”${sf.usernameUpload}” password=”${sf.passwordUpload}” serverurl=”${sf.serverurlUpload}” deployroot=”Retrieve” pollWaitMillis=”10000″ maxPoll=”100″ /> </target> </project> Go to the path where you stored these files and then Run commands as follows: Upload(Which you mentioned in your build.xml file as target) – For uploading components you mentioned in the Package.xml file. Retrieve– For downloading the Components information you mentioned in the package.xml file...

Read More
Salesforce Google Map Integration
Sep02

Salesforce Google Map Integration

Google Map Integration Integrating google maps into Salesforce                         Description of the requirement: Starting with description of the Project we have worked upon, there’s an app we created for searching and showing Account’s location on the Map and knowing a route map from one location to another location via some locations(Checkpoints).                            Solution we came with: For the requirement we used Google maps api which is in Javascript format. There are some predefined javascript functions used in the Google map api. We used Google Maps library whoz source is coming from a link i.e., “https://maps.google.com/maps/api/”.                                 There are several Javascript functions we used here which are as follows: Function to get the current location of the User by using the browser’s location. Get the current location of the User by using the browser’s location:                  var geocoder;            var map;            function initialize(){                geocoder = new google.maps.Geocoder();                    console.log(lon+’***latlon–‘+lat );                var latlng = new google.maps.LatLng(lat, lon);                console.log(‘***latlon–‘+latlng);                var myOptions = {                  zoom: 12,                  center: latlng,                  mapTypeId: ‘roadmap’ /* ,                  mapTypeId: google.maps.MapTypeId.TERRAIN */                }                                         map = new google.maps.Map(document.getElementById(“map”), myOptions);   Here we used “google.maps.Geocoder();” to access Google Maps API geocoding service.    We created an apex class method which will take Address of the Account as a string and will return a Geolocation for that address i.e., in Latitude and longitude of the string  address passed in the function as a parameter to it.   Suppose a string will be as shown below: public Account accObj{get;set;} // This is a getter setter method contains Account record. String address = accObj.BillingStreet+accObj.BillingCity+accObj.BillingPostalCode+accObj.BillingCountry;   Now we used the below method to get the Latitude & Longitude: Get the Latitude & Longitude: public static String getLatitudeLongitude(String address){        String location=”;         try{                Double latitude = null;                Double longitude = null;                            Http httpGetRequest = new Http();                HttpRequest httpReq = new HttpRequest();                system.debug(‘******Address—‘+address);                address=address.replaceAll(‘ ‘,’+’);                address = address.replace(‘\r\n’, ‘ ‘);                        address = address.replace(‘\n’, ‘ ‘);                        address = address.replace(‘\r’, ‘ ‘);                        system.debug(‘******After       Address—‘+address);       httpReq.setEndpoint(‘https://maps.googleapis.com/maps/api/geocode/json?key=’+key+’&address=’ +address + ‘&sensor=false’);                                                                                            //Authentication to google api            httpReq.setMethod(‘GET’);            httpReq.setTimeout(6000);            HttpResponse httpResponseAddress = httpGetRequest.send(httpReq);                system.debug(‘res body: ‘ + httpResponseAddress.getBody());                JSONParser parser = JSON.createParser(httpResponseAddress.getBody());                                    while...

Read More