Adsense

Tuesday, April 09, 2013

SalesForce.com Custom Object Permissions

I started work on my first custom Sales Force app today and ran into a problem. The problem occurs when you create a new Custom Object in Sale Force and try to let another user create an instance of that object via a Javascript button leveraging the Sales Force API. When the user clicks your JavaScript button, they get the following error when the API call fails.

 

photo

Sample Button JavaScript

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}
var obj= new sforce.SObject("YourCustomObject__c");

var result = sforce.connection.create([obj]); // Fails Here

 

”A problem with the OnClick JavaScript for this button or link was encountered:” With a fault code of INVALID_TYPE. The error mentions that you might have provided the wrong object name, which might be a problem, but I know that the button works for me. Just not the other user.

The solution is actually pretty simple. You have to give the user’s profile CRUD permission to your new custom object. You can do this from the settings screen for their profile. Setup->Manage Users->Profiles->Edit and look under the Custom Object Permission section. Give the profile Read and Create permission and the button should now work.

 

Capture