Posts

Showing posts from April, 2017

Salesforce.com:Debugging Salesforce Lightning Components

Debugging There are a few basic tools and techniques that can help you to debug applications. Use Chrome DevTools to debug your client-side code. To open DevTools on Windows and Linux, press Control-Shift-I in your Google Chrome browser. On Mac, press Option-Command-I. To quickly find which line of code is failing, enable the  Pause on all exceptions  option before running your code. To learn more about debugging JavaScript on Google Chrome, refer to the  Google Chrome’s DevTools  website. Enable Debug Mode for Lightning Components Enable debug mode to make it easier to debug JavaScript code in your Lightning components. Salesforce Lightning Inspector Chrome Extension The Salesforce Lightning Inspector is a Google Chrome DevTools extension that enables you to navigate the component tree, inspect component attributes, and profile component performance. The extension also helps you to understand the sequence of event firing and handling. Log Messages To help d

Salesforce.com:Debugging Aura Component Code

Debugging Aura Component Code There are a few basic tools and techniques that can help you to debug applications. Use Chrome DevTools to debug your client-side code. To open DevTools on Windows and Linux, press Control-Shift-I in your Google Chrome browser. On Mac, press Option-Command-I. To quickly find which line of code is failing, enable the  Pause on all exceptions  option before running your code. To learn more about debugging JavaScript on Google Chrome, refer to the  Google Chrome’s DevTools  website. Enable Debug Mode for Lightning Components Enable debug mode to make it easier to debug JavaScript code in your Lightning components. Salesforce Lightning Inspector Chrome Extension The Salesforce Lightning Inspector is a Google Chrome DevTools extension that enables you to navigate the component tree, inspect component attributes, and profile component performance. The extension also helps you to understand the sequence of event firing and handling. Log

Salesforce.com:Scanning the Salesforce Lightning code for Quality

Salesforce Lightning CLI Lightning CLI is a Heroku Toolbelt plugin that lets you scan your code for general JavaScript coding issues and Lightning-specific issues. This tool is useful for preparing your Lightning components code for LockerService enablement. Lightning CLI is a linting tool based on the open source ESLint project. Like ESLint, the CLI tool flags general JavaScript issues it finds in your code. Lightning CLI alerts you to specific issues related to LockerService. Issues that are flagged include incorrect Lightning components code, and usage of unsupported or private JavaScript API methods. Lightning CLI installs into the Heroku Toolbelt, and is used on the command line. Install Salesforce Lightning CLI Install Lightning CLI as a Heroku Toolbelt plugin. Then, update the Heroku Toolbelt to get the latest Lightning CLI rules. Use Salesforce Lightning CLI Run Lightning CLI just like any other lint command-line tool. The only trick is invoking it th

Salesforce.com:Developing Secure Code in Salesforce Lightning

Developing Secure Code The Salesforce Aura framework uses Content Security Policy (CSP) to control the source of content that can be loaded on a page. The LockerService architectural layer enhances security by isolating individual Lightning components in their own containers and enforcing coding best practices. The Lightning Component framework uses Content Security Policy (CSP) to control the source of content that can be loaded on a page. CSP  is a Candidate Recommendation of the W3C working group on Web Application Security. The framework uses the  Content-​Security-​Policy  HTTP header recommended by the W3C. The framework’s CSP covers these resources: JavaScript LibrariesAll JavaScript libraries must be uploaded to Salesforce static resources. For more information, see  Using External JavaScript Libraries .HTTPS Connections for ResourcesAll external fonts, images, frames, and CSS must use an HTTPS URL. You can change the CSP policy and expand access to thir

Salesforce.com:What is Aura Framework?

What is Aura   Aura is a UI framework for developing dynamic web apps for mobile and desktop devices. Aura provides a scalable long-lived lifecycle to support building apps engineered for growth. Aura supports partitioned multi-tier component development that bridges the client and server. It uses JavaScript on the client side and Java on the server side. Why Use Aura? Aura comes with a rich and extensible component set to kick start building apps. You don’t have to spend your time optimizing your apps for different devices as the components take care of that for you. The framework intelligently utilizes your server, browser, devices, and network so you can focus on the logic and interactions of your apps. The Lightning Component framework  is built on the open source Aura framework. The Aura framework enables you to build apps completely independent of your data in Salesforce.     Source : http://www.saasanalogy.com/what-is-aura-framework/ http:

Techniques for Optimizing Dataload Performance

The Salesforce platform is a robust environment in which native and custom applications can scale to large volumes of data very quickly while continuing to perform well. You can maximize the benefits of these capabilities by: Making queries selective—ensure that reports, list views, and SOQL are using appropriate filters. Reducing the amount of active data—use archiving, mashups, and other techniques to reduce the amount of data stored in Salesforce. Techniques for optimizing Salesforce performance The arrangements, features, mechanisms, and options underpinning those techniques Circumstances in which you should use those techniques and tailor them to your needs Mash UP One approach to reducing the amount of data in Salesforce is to maintain large data sets in a different application, and then make that application available to Salesforce as needed. Salesforce refers to such an arrangement as a  mashup because it provides a quick, loosely coupled i

Salesforce Integration Patterns and Practices

When you implement Salesforce, you frequently need to integrate it with other applications. Although each integration scenario is unique, there are common requirements and issues that developers must resolve. There are a some standard patterns to design a architecture of a particular business requirement. Pattern Scenario Remote Process Invocation—Request and Reply Salesforce invokes a process on a remote system, waits for completion of that process, and then tracks state based on the response from the remote system. Remote Process Invocation—Fire and Forget Salesforce invokes a process in a remote system but doesn’t wait for completion of the process. Instead, the remote process receives and acknowledges the request and then hands off control back to Salesforce. Batch Data Synchronization Data stored in Force.com should be created or refreshed to reflect updates from an external system, and when changes from Force.com should be sent to an external

Php and salesforce Integration

Hey All, I have been struggling around to integrate salesforce with third party services ie paypal,amazon s3 etc. So the first step for this is integration the Organization with our system with any language say php. So below are the step by step instruction to get data from salesforce. 1.) Get the salesforce php toolkit from  Github 2.)Create a php file that includes 2 files require_once(‘soapclient/SforcePartnerClient.php’); require_once(“soapclient/SforceHeaderOptions.php”); 3.)Create object of the class $sfObject = new SforcePartnerClient(); 4.) Download the WSDL of your org and add below code a.) To download the WSDL click Your Name | Setup | Developer | API $mySoapClient = $sfObject->createConnection(‘wsdl.jsp.xml’); 5.)Connect to the ORG $crmHandle = $sfObject->login($username, $password . $securityToken); Here $username=”Your Salesforce Username” $password=”Your salesforce password” $securityToken=”Your Salesforce Token” 6.)Finally the complete c

Salesforce Paypal Integration

This is my Second Post for the integration of Salesforce With 3rd party Softwares using the HTTP calls. We may find many ways to integrate 3rd party API’s but the best is to use HTTP class.As we may not find the free/open source APPS in APP EXCHANGE all the times. so below are the steps to integrate the Paypal With Salesforce.You can use this method for any service like fedex,Mobiletransact… and so on. 1.)In Develop | Security | Remote Site Settings Add https://api-3t.sandbox.paypal.com (For Sandbox). You need to get the Endpoint URL where the request is to be sent. 2.) Get the Paypal Sandbox Credentials for account (http://developer.paypal.com) You will need a.)Seller Account Username Password Api Signature b.)Buyer Account You need to get the credentials for the services you want to consume. Now as you have all the ground work done lets move to the implementation of the Apex code for integration. Now From The Api of the Service you want to integrate get the

Getting Reports From Salesforce to Custom Portal using php

Hey All, I have been searching ways to get data of the reports from salesforce to a Custom Web portal developed using php. Found a way of doing this using CURL extention of php. So Below are the steps .. 1.) Enable PHP_CURL in your php instalations. 2.) Create code for connecting to your instance as per my previous blog. $result = $client->login($username, $password); $client->sessionId = $result[‘sessionId’];  3.) Get the report ID from your instance using a webservice method in APEx WebService string FindReport(string ReportName) { List reports = [Select Id, Name from Report Where Name = :ReportName]; if (reports == null || reports.size() == 0) return null; PageReference pageRef = new PageReference(‘/’ + reports[0].Id); Blob ReportBlob = pageRef.getContent(); return ReportBlob.toString(); }Thanks to  David 4.)Define the URL to hit $url = “ https://na1.salesforce.com “; $reportUrl = $url.”/”.$reportId.”?export=1&enc=UTF-8&xf=csv”; 5.) Initi

Utlilze a Apex Webservice in php

I was looking to get some report id in my php code so found a workaround for that. we can make a Apex webservice method and call that in php. So below is the step by step process to do that. 1.) Make a apex webservice class and a method. To Create a class :- Develop| Apex Classes| New Here we are making a service to get ReportID for a given report name global class reportsManager{ WebService static string FindReport(string ReportName) { List reports = new list([Select Id, Name from Report Where Name = :ReportName]); if (reports == null || reports.size() == 0) return null; return reports[0].Id } } 2.) Download the WSDL xml for above class and save it in a source folder. To Download WSDL :- Develop| Apex Classes| WSDL(Save the file) 3.)Now in your php code make a function as follows. a.) Get connection to your org Refer Integration Blog . $crmHandle = $this->getConnection() b.)$sfdc = new SforcePartnerClient();// Making object of toolkit class c.)Create a variabl

Avoid Governor Limits

Salesforce is based on Multiteanet Architecture so they have imposed limits for the implementation of the Apex and customization of things. So the first and foremost challange in front of each developer is “Implementation of code avoiding governor limits”. So below are some tips and tricks to avoid governor limits The governor limits are applied on the basis of the initiation of the code execution. The execution initiates from :- Apex Trigger Apex Web Service Anonymous Block Visualforce Controller DML operations are basic needs of any implementation. so lets discuss the problem and the solution for this. 1.) Let’s have a look at the type of code that could cause this issue public void functionName(List theNames){ for(String theName: theNames){ myObject__c obj = [SELECT processed__c FROM myObject__c WHERE name=:theName]; //This may result in ‘Too many SOQL queries’ obj.processed__c = true; update obj; // Mistake #2 – may result in ‘Too many DML rows’ } }

Paypal Website Payment Standards in Visualforce

Sometimes we need to implement a functionality where we have to accept credit card payment but we just want to have a quick and simple process. Paypal website payment standards is the choice. What we need for this 1.) Business Account 2.) Force.com site where we can host this visualforce page 3.) Code to Accept IPNBelow is the code which will display a Buy Now button on visualforce page and you can change the amount based on your calculations <form action=”https://www.sandbox.paypal.com/cgi-bin/webscr” method=”post”> <input type=”hidden” name=”cmd” value=”_xclick”/> <input type=”hidden” name=”business” value=”YOUR BUSINESS EMAIL HERE”/> <input type=”hidden” name=”item_name” value=”ITEM NAME”/> <input type=”hidden” name=”item_number” value=”ITEM NO”/> <input type=”hidden” name=”amount” value=”1″/> <input type=”hidden” name=”notify_url” value=”IPN URL”/> <input type=”hidden” name=”custom” value=”YOU CAN PASS A CUSTOM VARIABLE

Custom Calendar on VisualForce Page

Image
There has always been a need to have a calendar component for visualforce page this kind of component can be used in events booking,events calendar,scheduling requirements and all the places where we need to show events by dates. This can be easily implemented using jquery,fullcalendar plugin and json in apex. So what we need here is 1.) Fullcalandar plugin  Download 2.) A custom object with start dates and end dates for events 3.) Apex class to pull data from object and convert that into json using json.serailze First we have to upload the fullcalendar lib to static resource and then we have to create a visualforce page with below code. The important thing is "JSONOFLIST" which is just json created from list of records by using JSONOFLIST = JSON.serialize(LIST OF SOBJECT); It will give you a calendar with items highlited on page Source : http://www.saasanalogy.com/custom-calendar-on-visualforce-page/

Salesforce integration Pattern: Remote Process Invocation—Request and Reply

Image
Problem When an event occurs in Salesforce, how do you initiate a process in a remote system, pass the required information to that process, receive a response from the remote system, and then use that response data to make updates within Salesforce? Considerations Does the call to the remote system require Salesforce to wait for a response before continuing processing? Is the call to the remote system a synchronous request-reply or an asynchronous request? If the call to the remote system is synchronous, does Salesforce have to process the response as part of the same transaction as the initial call? Is the message size small or large? Is the integration based on the occurrence of a specific event, such as a button click in the Salesforce user interface, or DML-based events? Solution The following table contains solutions to this integration problem. Solution Fit Comments A custom Visualforce page or button initiates an Apex SOAP callout in a

Salesforce.com: Call Apex webservice method from custom button

Many times we have a requirement to call a apex method from a custom button from standard pagelayout. Below is simple way to do this. 1.)Create a global class with a webservice method and call that from custom button using javascript onClick event. Create a global class global class OutboundEmails { WebService static void SendEmailNotification(string id) { //create a mail object to send a single email. Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); //set the email properties mail.setToAddresses(new string[] {'EmailAddress here'}); mail.setSenderDisplayName('SF.com Email Agent'); mail.setSubject('A new reminder'); mail.setHtmlBody('an object with ID='+ id + ' is just clicked on.'); //send the email Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail } ); } } And have a custom button with display type as “Detail Page Button” and Behaviour type as “Execute JavaScript”, content source as “onClick ja

Wrappers in visualforce and apex

Many times we have a requirement that we have to get a checkbox in pageblock table or a simple table and process items which are selected. So below is the solution.Problem: we need a checkbox in a pageblock table and process contacts which are selected Solution: Source  :  http://www.saasanalogy.com/wrappers-in-visualforce-and-apex/

Testing Example – Salesforce.com

As per the limits imposed by salesforce we have a need to create test classes for our code with minimum coverage for 75% of code. So below is the small example to create a test class To define an Apex method as a ‘test method’, simply define the method as static and add the keyword testMethod. A test method can be defined in any Apex class. A test method can not be defined in an Apex trigger. (Note: Testmethods cannot be called outside of a test context.) Use the isTest class annotation to define classes that only contain code used for testing your application. So the two possible ways to create test classes will be public myTestClass{ static testMethod void myTest() { //Add your test coverage code here } } Or @isTest public myTestClass{ public static void myTest() { //Add your test coverage code here } } There are times when you need to test large datasets for that there are two keywords Test.startTest and Test.stopTest.These static methods allow a te

What is Heroku

What is Heroku? Heroku (pronounced her-OH-koo) is a cloud application platform – a new way of building and deploying web apps. Benefits of PAAS Deployment using GIT Tracking Your App in Git $ git init Create GIT remote $ heroku create –stack cedar $ heroku create –stack cedar –remote staging $ heroku create –stack cedar –remote production Creating falling-wind-1624… done, stack is cedar http://falling-wind-1624.herokuapp.com/ | git@heroku.com:falling-wind-1624.git Git remote heroku added You can verify the remote in your git configuration as well: $ git remote -v heroku git@heroku.com:falling-wind-1624.git (fetch) heroku git@heroku.com:falling-wind-1624.git (push) Push Code to Heroku Remote $ git push heroku master $ git push staging master $ git push production master Stacks Available A stack is a complete deployment environment including the base operating system, the language runtime and associated libraries. As a result, different sta

Create Application on Heroku

This is a very basic tutorial to get started with heroku so below are the steps how you can create a small application and host that on heroku heroku  login Enter your  Heroku  credentials. Email: test@gmail.com Password: You Password Then it will give you below prompt Could not find an existing public key. Would you like to generate one? [Yn] Y Generating new SSH public key. Uploading SSH public key /root/.ssh/id_rsa.pub Authentication successful. After this create a  local directory mkdir app heroku  create –stack cedar Above command will create a instance for you on heroku Creating evening-mist-6047… done, stack is cedar   http://evening-mist-6047. herokuapp.com/  | git@ heroku .com:evening-mist- 6047.git Now we have to initiate GIT using: git init Now we have to push the root branch to heroku below command will do this for us git push  heroku  master Now since we have created a application on heroku we have to clone it and make a local insta

Salesforce.com : Create a webservice in salesforce/apex

Many times we have a requirement to create webservices which we want other systems to access. So there are a few things to be kept in mind while developing a webservice. 1.) Create a global class as a webservice class has be to globally accessible. global class MyWebService { } 2.) Create a Object for your webservice which will be used to hold data for your webservice as global class innerItems{          webservice string name;          webservice string DataId;          webservice string DataClass;                   public innerItems(){                    }      } 3.) All functions which you want to declare or expose in webservice must use webservice keyword  and have to be static.  4.) Now you can save the class and export the wsdl using the Generate Wsdl button on top of class     Source : http://www.saasanalogy.com/create-a-webservice-in-salesforceapex/

apex:actionFunction – Salesforce.com

There are times when we have to update components based on events on other parts of visualforce pages. So below is the code that can be used for reference. You can use below code for reference here we are updating a checkbox based on change in account source. <apex:page extensions=”testComponent” id=”thepage” standardcontroller=”Account”> <apex:form> <apex:inputfield value=”{!acc.AccountSource}”> <apex:actionsupport action=”{!changeCheckBox}” event=”onchange” rerender=”pan” status=”counterStatus”> </apex:actionsupport></apex:inputfield> <apex:outputpanel id=”pan”> <apex:inputfield id=”test” value=”{!acc.check__c}”> </apex:inputfield></apex:outputpanel> <apex:actionstatus id=”counterStatus” starttext=” (incrementing…)” stoptext=” (done)”> </apex:actionstatus></apex:form> </apex:page> public with sharing class testComponent { public testComponent() { } public Account acc{get;set

Salesforce integration Pattern:Remote Process Invocation—Fire and Forget

Problem When an event occurs in Salesforce, how do you initiate a process in a remote system and pass the required information to that process without waiting for a response from the remote system? Solution The following table contains solutions to this integration problem. Solution Fit Comments Workflow-driven outbound messaging Best No customization is required in Salesforce to implement outbound messaging. The recommended solution for this type of integration is when the remote process is invoked from an insert or update event. Salesforce provides a workflow-driven outbound messaging capability that allows sending SOAP messages to remote systems triggered by an insert or update operation in Salesforce. These messages are sent asynchronously and are independent of the Salesforce user interface. The outbound message is sent to a specific remote endpoint. The remote service must be able to participate in a contract-first integration where Salesforce pr

Salesforce.com: Plan Your Salesforce Implementation

Every Salesforce implementation is unique, that’s a given. If it worked the same for every business, there would be no need for an implementation partner. Having said that, there is one universal factor that applies to all businesses looking to get started on Salesforce for the first time: everyone wants the best start possible for their business on the platform.  So, assuming that:- You are committed to Salesforce The business case is signed off Do you have a inhouse Technical Expertise if not do you need a business process consulting partner(SME)? This is very important factor before selecting a partner because every implementation partner will give you different thoughts but what is good for your business is something which will be given by your internal experts or a business process consulting partner. First contact with a Salesforce Implementation Partner The best place to find a implementation (or ‘consulting’) partner is by taking a look on the  AppE

Salesforce.com: Getting Started with Lightning Component

We are creating a simple lightning component which will show some contacts on lightning app  and on lightning record page if we add that component to lightning page. Typical Lightning App Will look like this as you note we just have one component in this application. <aura:application extends=”force:slds”> <c:ContactsListing /> </aura:application> Lightning Component: A simple lightning component will have a controller, few attributes which will be used and handlers for various events like click, change the default is INIT which will be called on load of the component <aura:component controller=”ContactListingAuraController” implements=”force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes” access=”global” >    <aura:attribute name=”lstContacts” type=”Contact[]”/>     <aura:attribute name=”recordId” type=”Id” />    <aura:hand