Let's say I'm overriding the default retrieve operation for a Visualforce Remote Object so I can use custom SOQL to execute a query and add related (nested) data. In order to create a query, it'd be ideal to re-use Salesforce's parser that they use to take the Remote Objects Query Criteria containing
limit, to validate these and turn them into valid SOQL snippets I can use in my query.
Surely, this happens internally already, but is any such facility exposed to me, the developer?
@RemoteAction to override
retrieve like in this example https://salesforce.stackexchange.com/a/45193/7215. However, instead of calling
RemoteObjectController.retrieve, I want to call
Database.query('SELECT Id, Name, (SELECT Name FROM Orders__r) FROM Account' + criteria to get my results using dynamic SOQL.
My goal is to define the
criteria variable in this example. The resulting string might look like
WHERE Id = 'someSalesforceId' LIMIT 1 OFFSET 2 depending on the actual criteria, but this would ideally be validated against the object to make sure the fields were valid, and that SOQL injection didn't occur. I could build that myself, but Salesforce is obviously already doing this internally, so I wonder if we can reuse that logic.