Tuesday, August 9, 2011

Salesforce needs to copy Google's Spreadsheets for their Views.

Salesforce's views functionality is painfully outdated by todays standards, and is frankly embarrassing if you compare it along side the likes of what Google Docs or Office 365 can offer.

Some examples

  • You can't sub-sort on a column
  • You have a filter bar, but it only works one level, and you can sort after you filter
  • Re-sizing of columns is possible, but not sticky, you need to re-size them every time!
  • Sorting forces a refresh of the data, it could be done client side
  • You can only view 200 records at once.
  • You can display only 15 columns on one view




Lets compare this to the Google Docs spreadsheet offering.

  • Real filter tools, just like excel
  • Sub sorting works
  • Filtering combined with sorting works DING!
  • Sorting/filtering all happens on the client side, it's fast
  • Display up to 5000 records on one screen, and the UI is still fast
As most know, we can do a lot more in the browser today, with blindingly fast java script engines, rich libraries, hell, even local storage. Lets hope salesforce will do a refresh on one of the staple features of their product. Wizbang Jigsaw, Radian6, Chatter etc.. That's all great, but don't forget about these basics please!


Here are some posts on the idea exchange that already cover most of what I have pointed out. Please up vote these!





Friday, August 5, 2011

Using static resources with Salesforce custom Javascript buttons

Having hacked around with Salesforce's custom button that execute javascript, I quickly found myself needing to reuse code across other buttons within our CRM.

Salesforce has a Static Resources repository where you can store images, java script, even zip and jar files. Accessing said resources from the likes of Visualforce pages is a breeze;



Unfortunately, the $Resource variable has not been made available for use in custom buttons. However, we don't really need that variable to get a static resource into our Custom Button. All static resources are accessible via the URL in your salesforce org.

If you navigate to the Static Resources in your salesforce org, and click on the View File link;
You will see that the resource is accessible by a link as follows; https://yourorg.my.salesforce.com/resource/1312307963000/jbUtils

You could include this file directly into your custom button as follows:
{!REQUIRESCRIPT("/resource/1312307963000/jbUtils")}
but the maintainability of this approach will be extremely poor. If you play around with the URL a little more, you will find that the static resource is also available if you remove the string of digits, like this:
https://yourorg.my.salesforce.com/resource/jbUtils
however, this also will cause problems.

See Salesforce does a lot of caching in order to allow their systems to scale. The long string of digits is a cache buster. Every time you update your static resource in Salesforce, a new string of digits will be generated. In fact, the string they use is actually the date & time that you created or updated your static resource represented in Unix Epoch Time and padded out with three trailing zeros.

The $Resources variable takes care of all this magic for us, when used in Visualforce pages, but as it is left out from custom buttons, we need to get creative!

This task would be especially simple if we had some useful time/date functions as part of the Salesforce validation functions, but no such luck. One may think that we could use Javascript date/time functions, but not so fast! The {!REQUIRESCRIPT()} syntax is pre-processed by salesforce, long before it touches your browsers javascript engine.

So, we are left with creating a MacGyver-esque cash buster with the tools that we have. The static resources urls expect to receive a string 17 digits. No letters, hyphens or colons. The closest we can come to is NOW() which will give you a string that looks something like this: '2011-08-06 01:42:00Z' If we strip away the non numeric characters, we get this 20110806014200 which is 14 characters in length. Recall that the URLs expect 17 characters. Using the Salesforce substitution functions, we can create a valid cash buster. Behold the following monstrosity;

{!REQUIRESCRIPT('/resource/' & LEFT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(NOW()),':',''),'-',''),' ',''),10) & '000/jbUtils')}

Now, every time a user visits the page with your custom button, because NOW() always is a new, numerically larger string, the user will always get the freshest-cache-busted static resource available, and you are fee to reuse javascript code in all of your custom salesforce buttons!

Some words of warning; This is a hack, and if this method was to upset our kind Salesforce overlords, we could find the method breaking in the night. Hopefully, said overlords will find our cache-busting-ingenuity charming & cutesy, and reward us by giving us $Resources for our lowly custom buttons...



Monday, March 7, 2011

Hey Salesforce, Is "DE LOGIN" a new synonym for Logout, or a German login page?

The authentication methods to post to the plethora of salesforce community resources is a nightmare. Many times I have abandoned replying to a forum question, or adding a comment to an Idea posted in the Ideas exchange.

This morning, I was trying to reply to a post about a bug in version 21.0 of the Apex Data Loader on the http://forums.crmsuccess.com forums. I dutifully click Reply, and I'm prompted to login, which I do, and it appears to have succeed. Except, I don't see the reply text-area I expect, in fact, I don't see the same forums at all. I'm not even on the same damn forum any more. The salesforce authentication page has shipped me off to the http://boards.developerforce.com Force.com Discussion Boards!!?

I navigate back to the post on the http://forums.crmsuccess.com to reply, but I'm still not authenticated, I try again, and same thing, I end up authenticated on developer-force. I scratch my head, thinking what I have done wrong, because this must just be a case of me being dumb on a Monday morning. I look around, and I spot this gem:
What a odd way to display a "Logout" button? Or.. is this a login portal exclusively for Germans? How curious?

I click on that DE LOGIN button, get prompted for my credentials, which I enter, and click "Login" and where do I end up? In my production Salesforce Org.

To the person at Salesforce who had the bright idea to create a login button, on a forum, that is supposed to be an abbreviation of "Developer Edition Login" that logs me into my Salesforce org. You sir, are an idiot.