Thursday, February 10, 2011

Number field is always created as Decimal (internal type)

For all custom sObject in Salesforce.com.  Just learned this today:
http://boards.developerforce.com/t5/Apex-Code-Development/Integer-Double-or-Decimal/m-p/202075/highlight/false#M34823

So if you want to use the value in those fields in code for functions as non-decimal argument, a casting member function from Decimal (intvalue, longValue, doubleValue) is always in order, since Decimal sits right at the highest level of the implicit conversion hierarchy.

Useless Isnull() for formula

That's right, or to be gentler, next to useless in Salesforce.com formula.  Let's recount:
That's a large chunk of things you may want to check for null condition...  Why couldn't they have a more flexible, "overloaded" isnull()?


Wednesday, February 2, 2011

Client side vs. server side on Visualforce

What I needed to do was to disable a drop down box based on the selection in another drop down. Fairly common requirement. The controller drop down starts as disabled, so I set disabled property in , and used JavaScript from onchange to toggle disabled in HTML DOM from the controlling drop down. All sounded fine and dandy and the UI worked as it should, until I realized that the form never returned anything from the controlled drop down no matter what its status was.

It looks like the client side JavaScript did nothing to enable the controlled element. As far as the server was concerned, it's a field it can discard. I didn't do any HTML/JS debugging to confirm that, but it certainly felt that way. Once I switched the controlling mechanism to server-side processing/AJAX, it started to work as intended.

The only drawback with the AJAX way was that it's a bit slower. Action from the client-side Javascript was instant. With AJAX and its server round trip, it took about one second for the controlled drop down to change status.