Wednesday, November 20, 2013

Salesforce Apex: An unexpected error occurred

I got this when I defined a for loop as follows:

for (i=0; i<collection.size(); i++)

The fix is to correct the definition as follows:

for (integer i=0; i<collection.size(); i++)

Saturday, November 16, 2013

Epson Status Monitor disappears after installing Windows 8.1

Problem

After installing Windows 8.1, the Epson Status Monitor disappeared. Selecting Printer Preferences would bring up the unhelpful generic Windows info.

The Epson Status Monitor is a rather antiquated piece of software that is still used with the latest Stylus range of printers. Without it, you can't check ink levels or get detailed information about printer errors.



Solution


  1. Open Devices and Printers
  2. Right-click the printer and select Printer Properties
  3. Click the Change Properties button
  4. Select the Advanced Tab
  5. In the Driver dropdown, change the selection to use the correct driver. In my case, I had to switch from "Epson ESC/P Standard 3 V4 Class Driver" to "EPSON NX130 Series".


Friday, August 16, 2013

Disabling windows profile quota

Windows profile quota can be a real pain as it prevents you logging off until you have reduced your profile size. This can be incredibly inconvenient if you're in a hurry for something.

Go to the link below for some options to get around this problem.

http://realfixes.blogspot.com/2010/03/you-have-exceeded-your-profile-storage.html

Thursday, July 4, 2013

Salesforce Classic (Mobile) metadata not updating

Problem


App metadata is out of date and won't update, even if a full Refresh All Data update is done

Possible Cause


Subtle data corruption

Resolution


Perform an erase and reload as per instructions in KB5282

This KB describes serious corruption, but my experience is that the steps described solve this problem even if there is no visibly corrupted data.

Tuesday, June 25, 2013

Eclipse's Navigate | Open Resource menu option missing

The Eclipse "Open Resource" dialog is great but I tend to forget the keyboard shortcut (Ctrl-Shift-R), and I rely on the existence of the Open Resource menu option to remind me. However this menu option is often missing from my current project perspective.

These are the steps to add the Open Resource menu option to the current perspective:
  1. Window | Customize Perspective...
  2. Command Group Availability tab - check "Resource Navigation"
  3. Menu Visibility tab - check "Open Resource..." if it's not already checked
  4. OK

Tuesday, June 18, 2013

Salesforce "invalid query locator" error

Symptom


Inline apex soql query returns "QueryException: invalid query locator" error. However executing the soql directly does not present this error.

A Possible Cause


Apex appears to have a limit on the number of child records that can be returned from a soql query. At time of writing this limit is 999 records. AFAIK this limit is undocumented.

Solution


Separate any subqueries out into one or more separate queries.

Example


The following apex returns one myParent record and all associated child records for the myChild1, myChild2 & myChild3 objects.

myParent__c p=[select id, (select id from myChild1__r), (select id from myChild2__r), (select id from myChild3__r) from myParent__c limit 1];

If the total number of child records >= 1000 then you will get the "invalid query locator" error.

Let's say myChild3__c has a large number of records. Then the solution would be as follows:

myParent__c p=[select id, (select id from myChild1__r), (select id from myChild2__r) from myParent__c limit 1];


myChild3__c[] c3s=[select id from myChild3__c where myParent__c=:myParent__c.Id];

Tuesday, May 14, 2013

Salesforce Summer 13 - things I've noticed

Automated Apex Test Execution

The code at http://developer.force.com/cookbook/recipe/automated-unit-test-execution now produces different results.

In my case, the number of results has nearly tripled. Interestingly, the number of failed tests increased. This code shouldn't have excluded any failed tests, so it seems to me that there is a bug fix in Summer 13 for the ApexTestResult object. This means the outputs of this code prior to Summer 13 probably aren't trustworthy.

Developer Console - now slower than ever

I have to work with older versions of IE a lot (don't get me started). Prior to Summer 13, Developer Console was pretty slow but usable. Now I get a lot of hanging and the slow script dialog.