1

i am a .net developer and new to salesforce.

I have currently build a .net web application which queries account details from multiple salesforce orgs. I am using partner wsdl to dynamically pull the orgs metadata. The user(usually system administrator user in SF) who provides the credentials also selects which org he/she belongs to from a drop down.

I would like to know if there is any way i can determine which org the user belongs to and pull the orgs metadata/object's API name dynamically using the user's credentials? Similar to how workbench works.I do not want to generate and consume any wsdl from salesforce. I noticed that workbench is by default a connected app in every salesforce org. If i make my application a connected app in all the orgs i am querying from, will that let me determine which org the user belongs to? if so how? Maybe i am not understanding the concept to connected apps correctly.

Thank you!

0

You only need to get the Partner API once. It will be the same for every other org. The idea of the Partner API is that you can adapt to any org you connect to via the describe calls.

If you have the users Salesforce credentials (including security token) then you can establish a session with the Partner API and then query the UserInfo. The response will include the organizationId and organizationName. Note that the LoginResult also includes the UserInfo, so you won't even need to make an additional call.

0

A connected app created in one org can be used for other orgs. There is no need to create a connected app for each org.

While authenticating user, the request is sent to test.salesforce.com or login.salesforce.com (Maybe different if you have custom domain implemented). Since a username is unique across all orgs, Salesforce can automatically determine which org does the user belongs to, and will log you in provided that credentials are correct. You will be required to specify where do you want to send the request i.e Production/Developer or Sandbox.

If all of the orgs are production/developer, you can send request to login.salesforce.com.

After successful login, you can query using the sessionID generated to find the org information.

Since you dont want to consume any WSDL, you can query org's objects and fields using Salesforce Rest API.

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.