Optionalmetadata: UserPermissionMetadataPrivate#hasPrivatearrayReadonlydeveloperPrivatemetadataPrivatemetadataPrivateprofileReadonlytypeAdds or updates the access permissions for an Apex class. If the class does not exist in the current metadata, it will be added with the specified enabled state. If the class already exists, its enabled state will be updated if it differs from the provided value.
The name of the Apex class to add or update.
A boolean indicating whether access to the class is enabled.
Adds a field permission to the profile model. If the field already exists, its permissions are updated.
The name of the field to add or update.
The access level for the field, which can be 'editable' or 'readable'. - 'editable': Grants both read and write access to the field. - 'readable': Grants read-only access to the field.
Adds or updates the access permissions for an Apex page.
If the page already exists in the permissions list, its enabled status is updated.
Otherwise, the page is added to the metadata with the specified enabled status.
The name of the Apex page to add or update.
A boolean indicating whether the page access should be enabled.
Determines whether a user has access to a specific Apex class.
The name of the Apex class to check access for.
true if the user has access to the specified class, false if access is disabled,
or undefined if the class is not found.
Retrieves the field access permission for a specified field name.
The name of the field to check access permissions for.
The field access permission as a SalesforceFieldPermission value:
- SalesforceFieldPermission.editable if the field is editable.
- SalesforceFieldPermission.readable if the field is readable but not editable.
- SalesforceFieldPermission.none if the field exists but has no access permissions.
- undefined if the field does not exist.
Determines whether the user has access to a specific Apex class by name.
The name of the Apex class to check for access.
true if the user has access to the specified Apex class; otherwise, false.
Checks if the profile contains a specific field.
One or more strings representing the field name(s) to check.
If multiple strings are provided, they are joined with a dot (.) to form a composite field name.
true if the profile contains the specified field, otherwise false.
Checks if the user has access to a specific Apex page by its name.
The name of the Apex page to check.
true if the user has access to the specified Apex page; otherwise, false.
Loads and parses metadata XML content, merging the parsed data into the current instance.
The metadata XML content to load, provided as a string or Buffer.
The current instance with the merged data.
The method uses custom parsing logic to handle specific data types:
Array properties are determined based on the arrayProperties configuration.
Merges the provided partial user permission metadata into the current metadata object. This method normalizes keys to ensure case-insensitivity and handles merging of array values. If the key exists in the current metadata and is an array, the values are appended. Otherwise, the value is directly assigned to the metadata. Unmapped properties are preserved and added to the metadata.
A partial object containing user permission metadata to merge.
Removes access to an Apex class by its name from the user's metadata.
The name of the Apex class to remove access for.
Removes a field permission entry from the metadata based on the specified field name.
The name of the field to remove from the field permissions.
ProtectedremoveRemoves an item from the specified metadata and metadataUpdates arrays based on the provided key and name.
The key representing the property in the metadata object. This key must correspond to an array property.
The name or identifier of the item to be removed. This is matched against the field specified by PermissionNameFields[key].
Removes access to a specific Apex page by its name from the user's page accesses.
The name of the Apex page to remove access for.
Reset the change tracking on this profile.
Saves the current metadata changes to Salesforce using the provided connection. If there are no changes, the method returns immediately without performing any operation.
The Salesforce connection instance used to perform the metadata update.
Sets the visibility of a specific record type for the current profile. If the record type visibility already exists, it updates the visibility. Otherwise, it adds a new record type visibility entry to the metadata.
The name of the record type to set visibility for.
The visibility status to set for the record type. Defaults to true.
Sort all the entries in the profile alphabetically. All profile data is sorted in place.
This instance of the profile.
Convert the current profile object to XML metadata
Optionaloptions: { sort?: boolean }XML metadata representation of the current profile object
ProtectedupdateUpdate entries on an array property of the profile object. If the new value is different than the current value, the change will be tracked.
Property name to update
Value to set on the array property
Represents a Salesforce user permissions model, providing methods to manage and manipulate metadata for profiles and permission sets. This class allows for loading, merging, updating, and saving metadata related to user permissions, such as field permissions, object permissions, Apex class access, and record type visibility.
Remarks
Example