Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I am integrating salesforce in my ASP.NET application. I am able to every operation using partnerWSDL but needs to check managed application installed in an account. Like I am having a LMA on salesforce and every user should installed that LMA before doing intigration with my application so I just need to find my LMA whether it is installed or not.

share|improve this question

3 Answers 3

You can use the Metadata API (just import that WSDL separately), login with the Partner WSDL, assign the endpoint/session ID to the Metadata API binding, then call listMetadata from the Metadata API. The specifics will depend on your programming language.

PartnerConnection partnerApi = new PartnerConnection();
LoginResult loginResult = partnerApi.login(username, password);
MetadataConnection metadataApi = new MetadataConnection();
metadataApi.sessionHeader = new MetadataConnection.SessionHeader();
metadataApi.sessionHeader.sessionId = loginResult.sessionId;
metadataApi.setEndpoint(loginResult.serverUrl);
ListMetadataResult metadata = metadataApi.listMetadata('InstalledPackage');

This is only pseudo-code written from the top of my head, roughly Java-esque in nature, so your mileage may vary. However, it's pretty trivial to use this method, because it is synchronous and doesn't require polling. This method does not rely on the presence of a specific element, which could be deleted in a future version or not present in an earlier version (if you care about versions). The namespace is guaranteed to remain constant.

As a side note, once you've got that information, you can also retrieve a package to determine the version of the package, and also all of its contents, if you desire.

share|improve this answer

I had similar situation where i had to check if package XYZ is installed in my code.

My solution was just search for specific item from that package. If that item exists it means package is installed otherwise not.

SELECT Name,NamespacePrefix FROM ApexClass where name = 'XXX' and NamespacePrefix = 'ZZZ'

You can use this Query from SOAP API too.

share|improve this answer

Thanks It works. Please check the below code what I tried to get all the installed packages.

MetaDataWSDL.ListMetadataQuery query = new ListMetadataQuery();
query.type = "InstalledPackage";
MetadataService mBinding = new MetadataService();
mBinding.SessionHeaderValue = new MetaDataWSDL.SessionHeader();
mBinding.SessionHeaderValue.sessionId = binding.SessionHeaderValue.sessionId;
mBinding.Url = metadata.Replace("{version}","29.0");
FileProperties[] lmr = mBinding.listMetadata(new ListMetadataQuery[] { query }, asOfVersion);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.