MS SharePoint – Files – Delete Document Permission

Estimated reading: 5 minutes

MS SharePoint – Files – Delete Document Permission

Removes the permission identified by Permission Id from the specified item. Use a permission ID from Get Item Permissions, not a user ID or sharing URL. Inherited permissions cannot be removed at the child item through this operation; manage them at their origin. The result does not contain the deleted permission.

Action details

PropertyValue
Action labelMS SharePoint – Files – Delete Document Permission
CategoryCloudTools
Apex class and methodDeleteSharePointLibraryItemPermission.deleteLibraryItemPermission
Input typeDeleteSharePointLibraryItemPermission.DeleteSharePointLibraryItemPermissionInput
Output typeList<DeleteSharePointLibraryItemPermissionOutput>
AuthorizationOAuth Delegated (Authorization Code) or OAuth Application (Client Credentials), subject to endpoint restrictions.
Microsoft Graph requestDELETE /v1.0/sites/{siteId}/drives/{driveId}/items/{itemId}/permissions/{permissionId}

Prerequisites and permissions

Configure a CloudTools Connector with Connector Type set to Microsoft 365. Complete user sign-in for delegated access. For supported application access, grant application permissions and administrator consent. The calling identity must have access to the relevant site, list, library, or item; tenant policy and resource configuration still apply.

The action permission provider declares the following permission alternatives. These are not cumulative requirements and not all are least privileged. Check the linked Microsoft reference for the endpoint, authorization type, and current restrictions.

Permission typeDeclared alternatives
DelegatedFiles.ReadWrite, Files.ReadWrite.All, Sites.ReadWrite.All
ApplicationFiles.ReadWrite.All, Sites.ReadWrite.All

See the Microsoft operation and permissions reference.

Inputs

Supply one non-null request with nonblank required identifiers. IDs must belong to the indicated site, list, or drive; do not substitute Salesforce IDs or browser URLs.

InputApex fieldTypeRequiredDescription
Site IdsiteIdStringYesSharePoint site identifier.
Library IddriveIdStringYesLibrary (drive) identifier.
Item IditemIdStringYesLibrary (drive) item identifier.
Permission IdpermissionIdStringYesDrive item permission identifier.

The global invocable input does not expose connectorId. Direct subscriber Apex and Flow calls use CloudTools connector selection. Resolve dynamic values before invocation; this action does not resolve replacement tokens.

Outputs

Returns one operation result with success and message. It does not return a Microsoft resource. Handle callout exceptions in the caller.

OutputApex fieldTypeDescription
SuccesssuccessBooleanWhether the delete succeeded.
MessagemessageStringResult message.

Use in Flow

Add MS SharePoint – Files – Delete Document Permission in Flow Builder. Use a Microsoft 365 application connector configured as Set as default for Flow automations, supply the required resource IDs, and add fault handling. Delegated connections are not supported for CloudTools Flow automation. This implementation processes only the first input request and is not a bulk operation.

Use in custom Apex

This subscriber-org example uses the Apptigent namespace. Replace the identifiers, configure the connector, and run in a context that permits callouts. Arrange authorization before calling and handle exceptions in the caller.

Apptigent.DeleteSharePointLibraryItemPermission.DeleteSharePointLibraryItemPermissionInput request =
    new Apptigent.DeleteSharePointLibraryItemPermission.DeleteSharePointLibraryItemPermissionInput();
request.siteId = 'REPLACE_WITH_SITE_ID';
request.driveId = 'REPLACE_WITH_DRIVE_ID';
request.itemId = 'REPLACE_WITH_ITEM_OR_PARENT_ID';
request.permissionId = 'REPLACE_WITH_PERMISSION_ID';

List<Apptigent.DeleteSharePointLibraryItemPermission.DeleteSharePointLibraryItemPermissionOutput> results =
    Apptigent.DeleteSharePointLibraryItemPermission.deleteLibraryItemPermission(
        new List<Apptigent.DeleteSharePointLibraryItemPermission.DeleteSharePointLibraryItemPermissionInput>{ request }
    );

Boolean succeeded = !results.isEmpty() && results[0].success;
System.debug(succeeded);

Use in a Lightning Web Component

Use deleteSharePointLibraryItemPermission from msSharePointConnectorLib, through MSSharePointConnectorController. These c/ imports apply to an LWC in the same namespace. The function accepts one request object, including connectorId when applicable.

Connector selection limitation: This action delegates its Graph call to a shared file helper that does not receive the SharePoint request connectorId. It uses default Microsoft 365 connector selection. Supplying connectorId does not guarantee use of that record. Configure and authorize the default connector for this example.

sharePointActionExample.js

import { LightningElement } from 'lwc';
import { deleteSharePointLibraryItemPermission, MSSharePointObjects } from 'c/msSharePointConnectorLib';

export default class SharePointActionExample extends LightningElement {
    connectorId = 'REPLACE_WITH_CONNECTOR_RECORD_ID';
    result = null;
    errorMessage = '';
    isRunning = false;
    completed = false;

    async handleRun() {
        if (this.isRunning || this.completed) {
            return;
        }
        this.isRunning = true;
        this.errorMessage = '';
        try {
            const request = MSSharePointObjects.inputs.libraryItem();
            request.siteId = 'REPLACE_WITH_SITE_ID';
            request.driveId = 'REPLACE_WITH_DRIVE_ID';
            request.itemId = 'REPLACE_WITH_ITEM_OR_PARENT_ID';
            request.permissionId = 'REPLACE_WITH_PERMISSION_ID';
            const result = await deleteSharePointLibraryItemPermission(request);
            if (!result?.success) {
                throw new Error('The action did not return a usable result.');
            }
            this.result = result;
            this.completed = true;
        } catch (error) {
            this.errorMessage = error.requiresInteractiveAuthorization
                ? 'Sign in to Microsoft for the connector, then try again.'
                : error.message || 'The SharePoint action failed.';
        } finally {
            this.isRunning = false;
        }
    }
}

sharePointActionExample.html

<template>
    <lightning-button label="Run action" onclick={handleRun}
        disabled={isRunning}></lightning-button>
    <p role="alert">{errorMessage}</p>
</template>

The library resolves to one operation object with success and message.

LWC rawJson serializes the mapped Apex object; it is not the untouched Microsoft response or an additional global invocable output. Use getMSSharePointAuthorizationState, beginMSSharePointAuthorization, and createMSSharePointOAuthMessageHandler to arrange delegated sign-in. The library normalizes controller errors, including requiresInteractiveAuthorization when available; it does not automatically sign in or retry.

The example prevents repeating a completed operation. Reset completed only for a new deliberate operation. If a failure leaves the outcome uncertain, inspect the resource before retrying. For Copy, completed means the request returned, not that the background copy finished.

Error handling and troubleshooting

SymptomWhat to check
Required fields errorSupply a nonempty request list, a non-null first request, and the required identifiers or body values.
Authorization or access deniedCheck connector selection, sign-in, application versus delegated permissions, administrator consent, and resource access.
Resource not foundVerify the parent site, list, and drive IDs. Distinguish list item IDs from drive item IDs and retain permission or version IDs with their resource.
Missing fields or itemsCheck query inputs, first-page behavior, supported expansions, item type, and mapped output limitations.
Unexpected connectorReview the connector selection behavior described above and the Microsoft 365 default connector.
Operation rejectedInspect the Microsoft error, JSON field values, library or page state, supported API capabilities, and tenant policies.
Share this Doc

MS SharePoint – Files – Delete Document Permission

Or copy link

CONTENTS

Free eBook: The Ultimate Guide to Power Platform Custom Connectors

Antimanual

Ask our AI support assistant your questions about our platform, features, and services.

You are offline
Chatbot avatar
What can I help you with?

Subscribe

×
Cancel