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
$Abhi$$Abhi$ 

Is their any functionality parallel to 'runAs' available in apex classes

Hi.

 

I read the documentation for the ''runes'' method, and found that the method 'runes' can only be used in a test method.

 

I wanted to implement the same 'runes' functionality in the normal APEX class. That is , I wanted to execute certain block of code according to the user context specifid by me in the code.

 

So is this possible in normal APEX class? if yes then how can this be implemented.

 

Any pointers regarding this issue would be of great help.

 

 

Karthik@TMCKarthik@TMC

 

 

system.runAs(UserName)

$Abhi$$Abhi$

Hi karthik,

 

But this method call can only be used in a test method, whereas I want to implement the same functionality in normal APEX class.

bob_buzzardbob_buzzard

No, there is no way to switch the context of the user in apex code.  

 

SammyComesHereSammyComesHere

Make be you can make use of UserInfo Object t achieve this .

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_userinfo.htm

Saravanan @CreationSaravanan @Creation

Hi All ,

 

I am also facing same problem whether  you got any solution regarding this.

 

please let me know if you got .

bob_buzzardbob_buzzard

The only way I'm aware of to execute code in a different user context is via an inboundemailhandler service, as that has the user specific on the service.   Aside from that, you just can't do it.

Saravanan @CreationSaravanan @Creation

Thanks bob.

Saravanan @CreationSaravanan @Creation

Hi Bob ,

 

Could please explain me why the below secnario is not working 

 

 

I have 4 tab each tab have the action function with action status like when user click on the link we will provide 

loading and then we are displaying the record.(onclick off the tab by using action function tag)

 

in the class I have  queried the permission set Assigment for current logged in userand the class having the with sharing key word

 

if i login apart from admin profile and if i click i am getting insufficent previlliages error ,but if  i didn't use action function

tag then I am not getting any error

 

but for an non admin user if i give view setup and configure the is working fine action function.