Tuesday, August 7, 2012

Validation Errors when saving new Validation rule

The following error message was encountered when saving a new validation rule that referenced a single object relationship.

Validation Errors While Saving Record(s)

There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "The formula references fields across 11 relationships while only 10 are allowed. Please contact support at salesforce.com for more assistance.".

I found the message a bit confusing as there was only a single relationship referenced in the error condition formula. Going back to the validation rule edit page and pressing the Check Syntax button made the error clearer:

You have reached the maximum number of 10 object references on Opportunity

The other validation rules on Opportunity were already referencing 3 other objects across 10 different object references.

See also:

Friday, July 27, 2012

Salesforce "Missing Organization Feature: ProductSchedule" on managed package install

When installing a managed package the following error appeared:

Missing Organization Feature: ProductSchedule

This corresponds to the package requirements that were automatically checked when the managed package was uploaded.

This feature can be enabled in the target organization by checking the Scheduling Enabled for either Quantity Schedules or Revenue Schedules under App Setup > Customize > Products > Schedule Setup.

Monday, July 23, 2012

Apex Test cases fail when run in parallel

Currently, when running apex test cases via Apex Test Execution or ApexTestQueueItem records two cases execute at any one time.

Usually this isn't an issue, but if the test cases aren't fully isolated (i.e. they work on the same records) and data isolation is turned off failures can occur which wouldn't happen if they were run one at a time.

In my case I got the error message that the PriceBook2 (01s keyprefix) couldn't be updated:

System.DmlException: Update failed. First exception on row 0 with id 01s300000001OuYAAU; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: []

In the Summer 12 release there is now an option to run the test cases one at a time.
Your Name > Setup > Develop > Apex Test Execution > Options: Disable Parallel Apex Testing

Disable Parallel Apex Testing: Executes asynchronous tests one at a time. This helps prevent test interference on shared data when tests run at the same time and access the same data. This only occurs when tests don’t create their own data and turn off data isolation to access the organization’s data. This option doesn’t affect the asynchronous execution of tests, which continue to run asynchronously from the Apex Test Execution page.

The "unable to obtain exclusive access to this record" message has also been encountered when deploying a change set from the sandbox to production. What was particularly odd here was that the same change set had successfully passed validation but was not failing deployment. Disabling the parallel apex testing also resolved this issue.

Wednesday, July 4, 2012

Salesforce API_CURRENTLY_DISABLED: API is disabled for this User

The Partner API returned the following error for some new users accessing a system I maintain:

API_CURRENTLY_DISABLED: API is disabled for this User

In this case it was caused by the users Profile not having API access. Check
Administration Setup > Manage Users > Profiles > Users Profile > Administrative Permissions > API Enabled.

Monday, June 11, 2012

Salesforce - Custom List buttons for OpportunityLineItem

When trying to create a Visualforce Page to back a Custom List button for Opportunity Product (OpportunityLineItem) I got the following error:

Save error: List controllers are not supported for OpportunityLineItem.

From StandardController recordSetVar OpportunityLineItem issue:

"we restrict list controllers ( standardCOntroller + recordSetVar attribute) to only top-level standard and custom objects so effectively you can not create a list button to a Visualforce page for OpportunityLineItem today" Andrew, Product Manager (11-26-2008)

So that approach is out.

As I wasn't particularly interested in the specific records being selected I was able to make do with a URL content source that redirected to the required Visualforce page and passed the parent Opportunity Id.

As an aside, finding the buttons in the Related List Section required collapsing the Columns and expanding the Buttons area.

See Also:

Tuesday, June 5, 2012

Access standard Salesforce page regardless of Visualforce page overrides

If the standard Salesforce.com page has been overridden for a standard button or link you can still access it by appending nooverride=1 as a query string parameter to the url.

The Button and Link Overrides for Opportunity (pixels have been moved around)
Appended nooverride=1 for an OpportuntiyLineItem detail page.

Tuesday, May 29, 2012

Things that are missing from Windows Phone 7

I'm really liking my Windows Phone 7 devices (an HTC Trophy 7 and a Nokia Lumia 800), but some features that I'd really like to use are currently missing from the platform. The good news is that most of the current shortcomings could be fixed in software. I figure the most productive thing to do is voting in the two applicable uservoice feedback websites: