0

Hello Salesforce community,

  • I have 2 vf pages, and 1 vfp component.

  • Each page wraps the same component. The only difference in the pages is that one apex:page tag has readOnly="true" whereas the other page uses readOnly="false".

  • The visualforce component has sforce.connection.update routines defined within it which ideally would be toggled off when the page's readOnly="true". That seems to not be the case so I'm looking for an alternative way to cleanly deliver a page that reuses my component but disables all sforce.connection.update calls.

The confusing part is that despite readOnly="true" the sforce.connection.update DML updates are somehow allowed to occur (for what its worth im a system admin)

Given the setup above and without changing Profile object or field security, how can I cleanly/more-fully disable DML from occurring in the component on the page that has readOnly="true"?

Here are related articles, but I still am unsure why my readOnly="true" hack is not disabling DML.

Thanks in advance for any ideas / suggestions,

3

The readOnly attribute only prevents Apex code on the page from performing any DML, in exchange for higher governor limits (1,000,000 query rows). The sforce.connection script uses the API directly, not Apex, and is thus not subject to this restriction (it's also not subject to the 50,000 query row limit, as it can retrieve up to 50,000,000 rows as an API call). If you want to restrict DML operations in the component, write a parameter on the component to accept a Boolean value, and have your script check that value before performing DML.

4
  • Docs on “prevents [only] apex on page”? How on earth did you find them. :-) thanks either way! I googled “ajax| sforce.connection system mode user mode” with no luck – Peter Noges Oct 16 '20 at 19:53
  • 1
    @PeterNoges Experience. I actually expected the documentation to be more specific, but it isn't. I'm going to log a bug against that page this weekend to have the text amended. Just know that the connection.js file uses the API, and therefore isn't subject to the limits of Apex or Visualforce. – sfdcfox Oct 16 '20 at 19:58
  • @sfdcfox Can you provide more details on 50 million rows per API call. Is this applicable to if I am querying records using jsforce tool or this behavior is only for connection.js file? – javanoob Oct 16 '20 at 22:01
  • 1
    @javanoob The maximum query size for any API call is 50,000,000 rows. This applies to jsforce, connection.js, Data Loader, or any other tool that can run queries via the API. – sfdcfox Oct 16 '20 at 22:27

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.