1

Is it possible to get org Id when i install a manage package to any salesforce org. i.e. I have a managed package when it get installed in a org I want to get the org id and send it to an another org, where it get saved. Is this possible.

1

Yes, you can get the org id in post install script and post it to your ORG.

here is how to get org ID from .

Id OrgId = context.organizationId()

Here is how you can use InstallHandler Interface to automatically run your code which post the org id.

global class PostInstallClass implements InstallHandler {
    global void onInstall(InstallContext context) {
        Id OrgId = context.organizationId();    
        //call future method and pass OrgId
        //From future method call api and pass the orgID
    }
}

Ref : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_install_handler.htm

1

If you are using the LMA (Licence Management App), then a sfLma__License__c object will be added to the LMA Org when the managed package is installed. That object has a sfLma__Subscriber_Org_ID__c field that contains the org ID you are interested in. You can use normal salesforce techniques in the LMA org to respond to that insert and perform what ever additional processing you want.

  • I would really advise this. While @AtulRajguru9 's solution may work, why reinvent the wheel? the LMA gives you quite a few features out-of-the-box. – mkorman May 27 '16 at 9:45
  • Can you plz provide some doc related to this 'sfLma__License__c' object not able to find anything here. – Anu May 27 '16 at 9:58
  • @Anu Install the LMA and you can see the object definitions. – Keith C May 27 '16 at 10:47

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.