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
Salesforce Web to Lead Integration with Drupal 7
Feb08

Salesforce Web to Lead Integration with Drupal 7

Drupal is a CMS and Salesforce is a CRM. Ever thought to integrate these two platforms and explore new things and uncover the benefits which you get doing this? Salesforce is quite configurable and Drupal has plenty of modules to work upon as you wish. To make them synchronize to work them similar to web-to-lead form you just have to follow these steps: Install module in your Drupal 7 Org.: https://www.drupal.org/project/sfweb2lead_webform 2) Generate web-2-lead form from your Salesforce org. having fields you want to display in your webform. 3) Create a webform or clone the existing one. As you want. For cloning your webform there is a need to install following module: Node Clone: https://www.drupal.org/project/node_clone In order to create new form: Home>>Administration>>Content>>Add Content 4) Add title to your newly created web form. 5) Add components to your webform 6) In order to link it with Salesforce, click the option “Salesforce Web2Lead”. 7) Check the option asking to submit to Salesforce. Also, provide Lead Source for web form. 8) Now map your form fields with that of the Salesforce fields Administration>>Configuration>>Web Services>>Salesforce Webform While mapping fields you will be seeing a mapping table having two columns: Key: Webform fields Value: Salesforce fields NOTE: Enable debugging mode in it and you can see the logs of the data entered If you are integrating with your Sandbox Environment then provide “test.salesforce.com” instead of “www.salesforce.com” 9) To have a look on your Drupal log reports Administration>>Configuration>>Reports>>Recent log messages 10) Now you can check your leads in Salesforce STYLING YOUR WEBFORM After completion of your webform do you want to style it to make it more attractive? As an example let us show label inline of the form instead of displaying it alongside. What you have to do is just to install a new module Compact Form , configure it and you are done. Now go to: Administration>>Configuration>>User Interface Provide your webform id there NOTE: To know your form id you have to just inspect your form and get form id from there. Now this is how our web form looks like after styling: HOW TO INTEGRATE SALESFORCE PICKLIST VALUE WITHIN DRUPAL WEBFORM? It’s always helpful to know somethings extra. Make your form dynamic. For bringing Salesforce Picklist in Drupal 7 here are few steps to follow: 1 Install the module for it. It requires following: Drupal 7 Salesforce Suite 7.x-3.x Webform Behavior weights 2 Configure the module and you are done. 3 Just go to your webform components and add new Component. Choose type as Salesforce Picklist. 4 Choose a picklist present in your Salesforce Object which you want to join with your...

Read More