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

Login in to Different SFDC org using Apex

Hi ,
is there any way to login from one org into another org using Apex. Actually, i have written one Apex class and wanted to login into a different SFDC org from that class.

Please post me if anyone have any solution.

Thanks in advance,

Hi Naresh,


Did you get solution of this problem. I am facing the same problem and couldn't get any resolution.



Digamber Prasad


Also curious on whether there is any sample code for this one.  Saw some code with Apex Webservices API, but is there anything more direct with just using Apex Code in a Class and possibly Visualforce to get username and password and a picklist - choice of production or sandbox. 


You can accomplish this by taking the partner wsdl, and using wsdl2apex to generate apex code that can log into other orgs.


What is the use case for this?


You're either doing something badass, or you're doing something wrong.