A quick (silly) question.

Apex code runs under system user context.

What about "OnClick Javascript" on custom buttons and javascript code in VF pages ?

Under what context JS code execution run ?

2 Answers 2


The full answer to this question is technically complicated, but the easiest way to state it is that the OnClick call will follow whatever rules are enforced by the API being called. You'll want to be familiar with the semantics of whatever API call you're using. For standard SOAP and REST, this means that all user permissions will be enforced, and for custom SOAP and REST calls, the code will run in system context (with sharing optionally enforced, the same as Apex Code).


Foreword: There are smarter people than I regarding JavaScript. So you'll want to read up on the individual JavaScript contexts (http://davidshariff.com/blog/what-is-the-execution-context-in-javascript/) etc.

JS runs in the "context" of the browser, and it doesn't know anything more about the system or user than you tell it to. Loading a web page is (for our conversation) synchronous, or step by step, and the JS interpreter that parses scripts executes it as it reads it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.