+ Start a Discussion
Starz26Starz26 

Apex in System Mode and getContentAsPDF for Visualforce Security

If Apex runs in system mode, then why does getContentasPDF() not work if the user does not have access to the VF page.

 

I want to control when a page is generated via code. Because of the above, In order to do so I have to give the users access to the VF page and thus they can generate it anytime as long as they know the pagename and how to construct the url.....

 

 

ABHIKSARKARABHIKSARKAR

Can you please elaborate . 

Rahul SharmaRahul Sharma

Starz26,

 

Did you check whether the controller of the your visualforce page also runs in system mode.

Starz26Starz26

Rahul Sharma wrote:

Starz26,

 

Did you check whether the controller of the your visualforce page also runs in system mode.


Ahh, rookie move. A contractor did some of the code and used WITH SHARING. However I have removed that and still same error.

 

I will have to do some digging to ensure there is nothing elses blocking it..

Rahul SharmaRahul Sharma

Seems the problem with security access(Field or Object level security).

Try running the page for which you are performing getContentAsPdf for the user your getting error. And also ensure if the user is trying to access the records for which he is not having permissions.