Newer Version Available
PackageVersionHeader
A managed package can have several versions with different content and behavior. This header allows you to specify the version used for each package referenced by your API client.
If a package version isn't specified, the API client uses the version of the package specified in Setup. From Setup, enter API in the Quick Find box, select API, and then click Configure Enterprise Package Version Settings under Enterprise Package Version Settings.
This header is available in API version 16.0 and later.
Associated API Calls
convertLead(), create(), delete(), describeGlobal(), describeLayout(), describeSObject(), describeSObjects(), describeSoftphoneLayout(), describeTabs(), merge(), process(), query(), retrieve(), search(), undelete(), update(), upsert()
Fields
| Element Name | Type | Description |
|---|---|---|
| packageVersions | PackageVersion[] | A list of package versions for installed managed packages referenced by your API client. |
PackageVersion
Specifies a version of an installed managed package. A package version is majorNumber.minorNumber, for example 2.1.
Fields
| Field | Type | Description |
|---|---|---|
| majorNumber | int | The major version number of a package version. |
| minorNumber | int | The minor version number of a package version. |
| namespace | string | The unique namespace of the managed package. |
Sample Code—Java
This sample sets the package version for one installed package in the PackageVersionHeader. Next, it executes the code passed into this method via the executeAnonymous Apex method.
1public void PackageVersionHeaderSample(String code) throws Exception
2{
3 _PackageVersionHeader pvh = new _PackageVersionHeader();
4 PackageVersion pv = new PackageVersion();
5 pv.setNamespace("installedPackageNamespaceHere");
6 pv.setMajorNumber(1);
7 pv.setMinorNumber(0);
8 // In this case, we are only referencing one installed package.
9 PackageVersion[] pvs = new PackageVersion[]{pv};
10 pvh.setPackageVersions(pvs);
11
12 apexBinding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(),
13 "PackageVersionHeader", pvh);
14 // Execute the code passed into the method.
15 ExecuteAnonymousResult r = apexBinding.executeAnonymous(code);
16 if (r.isSuccess()) {
17 System.out.println("Code executed successfully");
18 }
19 else {
20 System.out.println("Exception message: " + r.getExceptionMessage());
21 System.out.println("Exception stack trace: " + r.getExceptionStackTrace());
22 }
23}