Salesforce License Information with APEX

If you want to get certain Salesforce user license information from within your org via APEX, such as TotalLicenses, you will have to either screen scrape the information from your org or sign up for Salesforces user license pilot program.

Signing up for the pilot program is a much better idea.  If you try to screen scrape, then the page layout you’re scraping from might change and you will need to keep up with page changes.

When you signup for the pilot program, the Salesforce documentation says it is only available through the SOAP API and this poses it’s own set of issues.  If you use the SOAP API, you will need to use the login method or add your current login session Id into the SOAP header.  If you need to use it in a scheduled job, you won’t have access to the current session Id.  I have a quick solution so you won’t have to deal with the complexity of using the API and storing login/passwords/tokens.

You can use Database.query

List<sObject> sobjList = Database.query('SELECT MasterLabel, Status, TotalLicenses, UsedLicenses FROM UserLicense');

for (sObject o : sobjList) {
    String sMasterLabel = (String) o.get('MasterLabel');
    String sStatus = (String) o.get('Status');
    Integer nTotalLicenses = (Integer) o.get('TotalLicenses');
    Integer nUsedLicenses = (Integer) o.get('UsedLicenses');

Thats it! You can avoid using the API (only if you signed up for the UserLicense pilot program).

1999 Ford Windstar Headlights Stay On, Wont Start

OK, so this post will be a little different from normal, but hopefully someone will find it useful.

Our 1999 Ford Windstar hasn’t been acting right lately, so we replaced the battery.  After hooking up the new battery, the running lights came on and the van wouldn’t start (the starter wouldn’t even engage).  No matter what we did, we couldn’t get the lights to turn off.  The radio would also turn on without the key in the ignition, and with they key in, the door/key chime wouldn’t turn on.  We checked every fuse and relay with the multitester, all tested good.

It turned out the problem was the ignition switch was bad.

WARNING: This vehicle contains SRS, or airbags, DO NOT WORK ON THIS AS AIRBAGS CAN ACCIDENTALLY DEPLOY AND BE VERY DANGEROUS.  If you choose to ignore my warning and still work on it yourself, YOU DO SO AT YOUR OWN RISK.  Be safe, disconnect battery and wait at least 5 minutes to reduce, not eliminate, chance of accidental airbag deploy.  Do not use any test equipment while part is still connected to van as this can also deploy airbags.

To change the ignition switch:

  1. Remove negative (black) cable from battery, then remove the positive (red) cable.  Dop not let red cable touch anything metal.
  2. Stop and wait 5 minutes (DO NOT SKIP, SEE AIRBAGS WARNING)
  3. Remove the 3 bolts at the bottom of the knee bolster and remove
  4. Remove the 2 bolts from left/right side the metal cover under knee bolster
  5. Remove 3 screws from lower steering column and remove only lower steering column
  6. Locate ignition switch and remove 2 screws from ignition switch
  7. Disengage ignition switch from actuator pin
  8. Unscrew wire harness from it
  9. Reinstall using exact opposite procedure

I suggest when reinstalling, test after screwing new ignition switch in.

Thats it!  Van works perfect.


Making a J-Pole antenna is very easy to do.  The antenna can be made from various materials, such as copper pipe or 300 ohm twin lead.

A – Long Section
B – Short Section
C – Feed Point
D – Gap

XBMC on Raspberry Pi

I have been playing around with the Raspberry Pi and XBMC a lot lately.  It has come a long was since it 1st came out.

I really like Openelec XBMC distro because it really does make the Raspberry Pi feel like an appliance since there is really almost no configuration necessary, it just works.  Most partitions are read-only, so if it crashes, you don’t have to worry.  But, that being said, it makes it a lot harder to tinker with.  I couldn’t get a GPIO remote to work and it was a pain to get other software installed on it.  It’s perfect if you have a USB remote sensor and you want to set it and forget it.

Raspbmc is another XBMC distro.  It is now on RC4 and its getting really good.  I like it a real lot.  Boot up times are not as good as Openelec, but since you boot it up once, then just let it go, it’s not a big deal.  It is based on Debian, so installing extra software is a breeze.  Also, since they have switched over to hardfp and other XBMC tweaks, it’s FAST!  Also, it comes with the lirc_rpi IR sensor kernel driver so getting a cheap ($1) remote sensor working was easy..

All in all, both distro’s are really coming along nice.  It’s impressive that the Raspberry Pi can do all that, or should I say it’s impressive with all the hard work that the developers did it get it to run on the Raspberry Pi.