+ Start a Discussion

Determine (true/false) whether the user has API access

I am loading the AJAX toolkit into a Visualforce page because the API has functionality in it that Apex does not support. Whether the user has API access or not, the script loads fine and the sforce object is created.


Within the sforce Javascript object, I don't see anything indicating whether a user has API access or not.  If I run a call (e.g. sforce.connection.describeGlobal()), a user without API access returns an error.


When the page loads I want to have a script invoked that tests whether the existing user has API access or not and result it in a true/false variable that I'll keep on the page.  I will then use the results of that variable to turn on/off functionality for the page.


Can anyone help with a safe function to run that accomplishes can test whether API access is turned on and return true or false?  I've tried, but have had trouble catching all the possible errors.  I need it so that no Javascript errors are thrown because that kills IE and looks ugly in the console of the other browsers.


What about enclosing a simple test call in a try/catch block to check for an error?


Best Regards,






You can use this and hope you purpose will be solve.