---
schema_version: "1"
id: 0ab27bd50d7765563a255cc17ae10de35b3f43dfae4d2456fd9173a19e070347
title: CustomPermissionDependency
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/object_reference/sforce_api_objects_custompermissiondependency.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_custompermissiondependency.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 7c67a7c503ab262d3cb31afab2c3eabc712b455227571d78959d8bd6243585a8
description: Represents the dependency between two custom permissions when one custom permission requires that you enable another custom permission. This object is available in API version 32.0 and later.
---
# CustomPermissionDependency

Represents the dependency between two custom permissions when one custom permission requires that you enable another custom permission. This object is available in API version 32.0 and later.

## Supported Calls

describeLayout(), describeSObjects(), query(), retrieve()

## Special Access Rules

As of Spring ’20 and later, only users with View Setup and Configuration permission can access this object.

## Fields

| Field Name | Details |
| --- | --- |
| CustomPermissionId | 
Type

reference

Properties

Filter, Group, Sort

Description

The ID of the custom permission that requires the permission that’s specified in RequiredCustomPermissionId.

This is a relationship field.

Relationship Name

CustomPermission

Relationship Type

Lookup

Refers To

CustomPermission



 |
| RequiredCustomPermissionId | 

Type

reference

Properties

Filter, Group, Sort

Description

The ID of the custom permission that must be enabled when CustomPermissionId is enabled.

This is a relationship field.

Relationship Name

RequiredCustomPermission

Relationship Type

Lookup

Refers To

CustomPermission



 |

## Usage

The following Apex class contains a method that returns the IDs of all custom permissions that are required for the given custom permission ID. To use this class, save it in your organization.

public class CustomPermissionUtil {
   public String\[\] getAllRequiredCustomPermissions(String customPermId) {
      return getAllRequiredHelper(new String\[\]{customPermId});
   }
   
   private String\[\] getAllRequiredHelper(String\[\] customPermIds) {
      CustomPermissionDependency\[\] requiredPerms = \[SELECT RequiredCustomPermissionId
                                                    FROM CustomPermissionDependency
                                                    WHERE CustomPermissionId
                                                    IN :customPermIds\];
      String\[\] requiredPermIds = new String\[\]{};
      for (CustomPermissionDependency cpd : requiredPerms) {
         requiredPermIds.add(cpd.RequiredCustomPermissionId);
      }
      if (requiredPermIds.size() > 0) {
         customPermIds.addall(getAllRequiredHelper(requiredPermIds));
         return customPermIds;
      } else {
         return customPermIds;
      }
   }
}

For more information about using Apex classes, see the [Apex Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/apex_dev_guide.htm).

#### See Also

- [CustomPermission](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_custompermission.htm "Represents a permission created to control access to a custom process or app, such as sending email. This object is available in API version 31.0 and later.")