function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RPanebiancoRPanebianco 

Permission and Future Method

Hi all,

I created a flow that call an apex class to run an asyncronous method to collect several data.
When I run flow as system administrator, everything is working as expected; method is executed in the future and flow is completed.

This flow should be used by Sales Rep, but future method is not enqueued because of following error.

You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.

I tried to understand which kind of configuration was missing; but the only way to execute method is to enable 'Modify All Data'. According to me, this is not a great solution. Do you have any idea how I can achieve my goal without enable 'Modify All Data' option.
KrishnaAvvaKrishnaAvva
Hi,

To begin with make sure that the Sales Rep  has access to all the data (fields/records/objects) for the data being collected. Its mosty the issue that they would not have read access if you just trying to consolidate some data.

Regards,
Krishna Avva
RPanebiancoRPanebianco
Hi,

I forgot to say that same method is working if it is perfomed without @future annotation.
I think that if issue is related to access permission on object used inside method, I should receive same error even if it is executed in a syncronous way. Maybe there is an extra check when method is added to scheduled job.

Regards,
Raffaele
SarvaniSarvani
Hey,

I am not sure if this is causing the issue but I recommend checking the security on the apex class, you are executing. Go to Quick Find -> Apex Classes -> Find security option beside your apex class and see if the sales reps profile has permission to execute that class.

Hope this helps,

Thanks,
Sarvani
RPanebiancoRPanebianco
Hi Sarvani,

I followed your suggestion, but unfortunatelly I received same error message. 

I also created a test class that run as sales rep and it is working fine; test is completed successfully. I'm confused about this behaviour.

Regards,
Raffaele
bhavik shah 4bhavik shah 4
Hi Raffaele,

Did you find the reason. I am facing the same issue.

Regards,
Bhavik