Retrieves the permissions for a specific document.

This function performs an asynchronous request to the server to fetch the permissions associated with a document of the specified type. The permissions returned indicate what actions the current user can perform on the given document.

// Retrieve permissions for an 'Employee' document.
const permissionParams: getDocPermissionParams = {
doctype: 'Employee',
docname: 'EMP-001',
};
const employeePermissions = await getDocPermission(permissionParams);
console.log(employeePermissions); // Logs the permissions for the 'Employee' document
// Retrieve permissions for a 'Product' document.
const permissionParams: getDocPermissionParams = {
doctype: 'Product',
docname: 'PRD-123',
};
const productPermissions = await getDocPermission(permissionParams);
console.log(productPermissions); // Logs the permissions for the 'Product' document
// Retrieve permissions for an 'Order' document.
const permissionParams: getDocPermissionParams = {
doctype: 'Order',
docname: 'ORD-456',
};
const orderPermissions = await getDocPermission(permissionParams);
console.log(orderPermissions); // Logs the permissions for the 'Order' document

Throws an error if the request fails or if there is an issue with retrieving the permissions.

  • Parameters

    • params: getDocPermissionParams

      The parameters for retrieving document permissions. This includes:

      • doctype: The type of document for which permissions are being retrieved.
      • docname: The name or identifier of the document for which permissions are being checked.

    Returns Promise<DocPerm>

    A promise that resolves to the permissions of the document. The returned permissions include the actions that the current user can perform on the document, such as 'read', 'write', 'create', 'delete', etc.