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
Faiza NazFaiza Naz 

How to identify package is installed in the system?

Hi,
I have a requiremnt where i want to know that specfic pacakge exsist in the enviroment or not.If it is not present in the enviroment than show an error.
 Is there any way to identify that an specfic package is installed in the enviroment or not via using apex?
Any one who as idea/sample code regarding this please help.

Thanks,
Cyrus TalladenCyrus Talladen
Faiza have you tried the setup page?  There is a link on the lower part of the sidebar in the setup page labelled "Installed Packages". Is this what you meant?
 
Faiza NazFaiza Naz
Thanks Cyrus for the reply, but I am not asking about "Installed Packages" link.

I have  a requirment that if a certain chceckbox mark "true" from UI.A code snipt run in backend(apex code) and check that an specfic package (e.g Package name "ABC")is installed in the system.If that package is installed in the enviroment its fine but,if it is not presnst in the enviroment show an error to the user that the package you requested/selected is not present in the enviroment.Please first install this pacakge.

Any one who has idea/sample code please share.It will be of great help.

Thanks,
Faiza
Cyrus TalladenCyrus Talladen
I'm not exactly sure if that requirement is at all feasible since managed packages are restricted code due to their third-party nature.  You can try accessing the API of that certain package if it is unrestricted, for example:
 
public class MyClass{

import com.that.package.*;

public constructor(){
   
    package.SObject packageObj = new package.SObject();

    packageObj.method();
   }
}
 
Cyrus T
www.levementum.com
Faiza NazFaiza Naz
Thanks for the reply Cyrus.This code is a great help.I will try this.

Thanks again!

Faiza