In apex you can create your own REST services quite simply:

global class REST_Service {
    global static string getDummytMessage(){
        return 'DUMMY DATA';

Salesforce does not allow such a class to be annotated as @ReadOnly, I would like to understand and know why this is the case.

update: potentially there is no technical reason and its just not there out of a project management perspective. I've created an idea to put it on the radar.

  • 1
    It looks like Salesforce implemented support for the @ReadOnly annotation in Summer '20 (API Version 49). Nice! – BrianS Sep 10 at 1:43

Thats a good question, and a reasonable one given that it is supported for Web Services defined via Apex. As to the reason for this, given both contexts are functionally the same from our perspective as developers. I am at a loss as to provide a reasonable hypothesis outside of knowning the code base of the platform.

I would suggest raising an IdeaExchange for it (had a quick check and could not see one) and perhaps raising a support case to enquiry as to if this is at all on the immediate radar to release this support.

| improve this answer | |

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.