Skip to main content

Posts

Showing posts with the label visualforce

Four secrets to improve the usability of your visualforce/Lightning pages on Salesforce

In the immortal words of a certain machine returning back in time, I am back. For now. After procrastinating for over a year and drafting a lot of rants- I am back with a very important coding lesson for you. For now. When we are designing a Visualforce page or an app or a lightning component (added that only to trick google) or any web page for that matter, we often tend to wrap up things quickly. Ask anyone on the team, how to design a good User Experience? and the person will immediately throw buzz words like Bootstrap, angular and other useless libraries (did someone squint?) Ok, Bootstrap, Angular-Js, and all the libraries are really cool and are useful in designing a fabulous UI. They are helpful in creating responsive pages that will work on all the devices but this post is not about those. Nope. For the purpose of this post, all the external libraries and buzzwords you use to decorate your resume are useless. (Adding Angular JS in your resume for a Salesforce consultan...

Code-pattern for Creating Mind-blowing Tabular Reports on Visualforce (With Sample code)

Salesforce.com has a mind-blowing reporting structure but it limits on data that is available on the system. Can we report on Data that is not present in the system? For e.g., in a time-sheet management system, can we identify the people who have not filled time-sheets for a particular day? Can we report on data that is not present in the system? Can we identify records that are not created? There is one thing I have learned working on Force.com platform for last 7 years, there is No No answer in Salesforce. Think a little bit and the answer will reach you. It is somewhat like climbing mount Everest, can you do it? Sure yes, in how many days depends on how fit I am (or how crazy I am) Ok that Everest thing came up because someone did ask me that a few weeks back, moving on. Someone did also ask me about creating a report on missing details and I gave it a thought. The short answer is Yes we can, the long answer is we write a Visualforce page, anyone can tell you that. But what I r...

The AngularJS angle to Visualforce

If someone had mentioned that I would be working on AngularJS a couple of months back, I would have laughed of with that idea. I am a force.com platofrm purist and can work wonders on the platform. Perhaps use jquery for the little magic tricks here and there but thats there. However, as it happened a few weeks back I was introduced to the AngularJS and I cannot be more excited about the technology. A couple of nights in the past I have been deep diving into EggHead  to learn AngularJS and have seen in wonder the possibility of Angular $Scope powered with visualforce platform. After dabbing myself into a bit of Angular, here is first thought on the technology. The easiest way to implement angular is to include the ng-app on the Apex:page <apex:page applyhtmltag="false" showheader="false" sidebar="false" standardstylesheets="false"> <html lang="en" ng-app="myApp" ng-controller="AngularController"> ....

Improving the user experience using visualforce

One of the biggest question customers have when implementing a CRM solution is how much can we automate the process? Considering that the representative will be spending 8-9 hours on the computer operating on CRM, the biggest question they ask is, 'Are you making my life easier or harder?' During a recent conversation on twitter this question popped up again. Is it possible to auto-populate the values on a visualforce page on choosing a lookup? Lets say you are designing a custom contact manager page. The page contains 4 fields from Account on the page including a lookup. When the user chooses a account value from lookup he would like to see the other 3 fields automatically populated, Sample visualforce code <apex:page standardController="Contact" extensions="AutopopulateController"> <apex:form> <apex:pagemessages id="msgs"/> <apex:pageblock title="Contact Create/Edit"> <apex:pageblocksec...

Solution for ActionSupport on Lookups for a Visualforce Page

Hello there, There are two reasons why you are on this page, one is that you like to go through Force.com blogs and gain as much knowledge as you can. Its a good thing, only you won't gain any knowledge reading the blogs but by digging. Two, you are highly frustrated and have Googled extensively for keywords 'ActionSupport', 'Lookup' and 'Visualforce' for many hours and before that were struggling with ActionSupport, onblur, onChange and other events. If you are here for second reason, we both sail in the same ship and even though I may sound like a telemarketer who is keen on wasting your time, I however, would like to inform you that I am sympathetic towards you. After having struggling to get this thing work on a Lookup for a long time, I decided to embark on the journey that took me back in time even before Salesforce.com existed. I went to the very depths of DOM and source code. Right to the birth place... ok not really, but I am just back from Star...

Override a standard button with Visualforce and Running round and round in circles

Are you that person who overrode the standard button with an awesome Visualforce page. Your page is beautifully working and then at the end want to send the user to the original page which you just override. Hey you think to yourself, all I got to do to is, copy the original URL in address bar paste it in notepad and add it to the page. As simple as riding a bike. If you did think this way, you are in for a surprise. Life is not exactly as easy as it seems, for when you override a standard Salesforce button or the link, you automatically override the original page too. So your little plan goes down the drain and all we see in a infinite loop like this. It was many many many years ago when I wasted an entire night in this vicious circle and decided to tell you a magic spell to help you out to break out of the circle. When you pass on the URL of the original page in the Visualforce controller, simply add a URL parameter noOverride=1 for e.g., suppose...

Some PDF tricks on Visualforce: Landscape, A4, page number and more

The beauty of Visualforce is simplicity. Remember the shock you received when you were told the entire page renders as PDF if you just add renderAs=PDF to the Page tag. For those who thought I spoke alien language right now, here is the trick, to render a page as PDF, we add a simple attribute to the <apex: page> tag <apex: page renderAs='pdf'> This will render the entire page as PDF. Now, say we need to add some extra features to the PDF. Like a page number in the footer or we need to render the page in landscape mode. Faced with this problem, I put on my Indiana Jones hat and went hunting for it in the vast hay-sack of the internet (read: googled extensively). Imagine my happiness when i found a big big page with many big big examples to solve the problem. The document I am referring to is from W3C, paged Box media . Long story short, I now possess the ultimate secret of rendering the page in any format I want. So here are few tricks I learned...

Loading animation on Visualforce

Maybe its just be but even if you build the most amazing system in the world, it won't be awesome if it is not visually pleasing or beautiful UI. No font should not be uneven, or the images should not haywire. Everything should be in order. Perfect. A simple script can save you a long email, informing you that a million dollar system is broken because it does nothing when users click the buttons. If you have a long processing happening in the background, its not good to assume your users are psych to know whats happening in background (if only we could see data packets send one by one).  If you do not show them that something is happening, they will end up clicking the button again and again, sending multiple request to the server. Worst case scenario your system will be returned back with a thank you note that excel sheet was better, this is broken. Have no fear, I am here. If you have been following this blog for some time, I hope you do, you will know t...

Generating Barcode image on Visualforce and Formula Field: Salesforce Code Tip

Can we generate bar-code image on Visualforce? Yes, Can we make it a field on page layout? Also yes. There are many API's available that help us achieve that. One such API is from  http://www.searchupc.com . The API is very easy to use. Visualforce usage: 1. The {!variable} will possibly be the SobjectVariable ({!sobject.fieldname}) or some {!variable} that stores the UPC code(possibly generated from algorithm.) The output: Formula Field Usage: i) Create a formula field with output as 'Text' ii) Use the below formula, replacing the mergeField with the field you store your UPC number. image("http://www.searchupc.com/drawupc.aspx?q="+ mergeField ,"Barcode") The Output: Works like a charm. Word of Caution:  i) The API accepts only 12 and 13 digit of UPC number. Any other digit and it does not render image. ii) The data is obviously not secure as we are passing the UPC code as a plain text to the server, there is a risk of packet sni...