Friday, December 2, 2011

Salesforce INSUFFICIENT_ACCESS: Upsert requires view all data on a non-unique custom index

INSUFFICIENT_ACCESS: Upsert requires view all data on a non-unique custom index

I recently encountered this error when trying to do an upsert through the Partner API using a particular users session. For other users it works fine.

Here is the same message with the important part emphasised: "INSUFFICIENT_ACCESS: Upsert requires view all data on a non-unique custom index". This also ties back to the Partner API upsert documentation:

If you are upserting an object that has the External ID attribute selected but not the Unique attribute selected, (a non-unique index) your client application must have the permission "View All Data" to execute this call. Having this permission prevents the client application from using upsert to insert an accidental duplicate record because it couldn’t see that the record existed.

The "View All Data" permission is set under the Administrative Permissions section of a profile.

As per its section (Administrative Permissions) and typically only being assigned to the System Administrator profile it is a fairly powerful permission to have. From the help doc:

Permission Name Description Functions Controlled Profiles
View All Data View all organizational data, regardless of sharing settings. View all data owned by other users System Administrator