PackageLicense

Represents a license for an installed managed package.

Introduced in API version 8.0.

describeSObjects(), query(), retrieve()

  • Customer Portal users can’t access this object.
  • Type: int
  • Properties: Filter, Group, Sort
  • Description: The number of users allowed to use the package.
  • Type: datetime
  • Properties: Filter, Nillable, Sort
  • Description: The date and time when the package license expires.
  • Type: boolean
  • Properties: Defaulted on create, Filter, Group, Sort
  • Introduced: API version 53.0
  • Description: Reserved for future use.
  • Default value: false
  • Type: boolean
  • Properties: Defaulted on create, Filter, Group, Sort
  • Introduced: API version 9.0
  • Description: Reserved for internal use.
  • Default value: false
  • Type: boolean

  • Properties: Defaulted on create, Filter, Group, Sort

  • Introduced: API version 66.0

  • Default value: false

  • Type: string
  • Properties: Filter, Group, Sort
  • Introduced: API version 31.0
  • Description: The namespace prefix associated with the package.
  • Type: picklist
  • Properties: Filter, Group, Restricted picklist, Sort
  • Description: The status of the license. Possible values are: Active, Expired, Free, and Trial.
  • Type: int
  • Properties: Filter, Group, Sort
  • Description: The number of users who have a license to the package.

Use this object to determine the number of licenses allowed and in use for a managed package installed in your organization.

The following example demonstrates the use of the API to manage licenses for a package. The example defines an Apex class that does the following.

  • Retrieves the PackageLicense record for the specified package (identified by its namespace prefix).
  • Defines a function that returns a list of all users with the specified profile.
  • Creates a UserPackageLicense record for each user with that profile, which has the effect of assigning a license for the package to all users with that profile.
  • Returns an error message if the number of users exceeds the number of available licenses.