MS Outlook – Folders – Update Folder

Estimated reading: 6 minutes

MS Outlook – Folders – Update Folder

Update Outlook folder. Uses the selected mailbox and returns the available result.

Renames a folder by sending { "displayName": "your-name" }. It does not move the folder or modify other properties.

Action details

PropertyValue
Action labelMS Outlook – Folders – Update Folder
CategoryCloudTools
Apex class and methodUpdateMSOutlookFolder.updateFolder
Input typeUpdateMSOutlookFolder.UpdateMSOutlookFolderInput
Output typeList<MSOutlookFolder>
AuthorizationOAuth Delegated (Authorization Code) or OAuth Application (Client Credentials).
Flow automationUse an application connector configured as the Flow default.
Microsoft Graph operationPATCH /v1.0/me/mailFolders/{folderId} for Authorization Code Flow; otherwise PATCH /v1.0/users/{userIdOrPrincipalName}/mailFolders/{folderId}.

Prerequisites and permissions

Configure a CloudTools Connector with Connector Type set to Microsoft 365. Complete Microsoft sign-in for delegated access. For application access, grant application permissions and administrator consent, supply the target mailbox user ID or principal name, and ensure the app can access that mailbox.

Microsoft requires Mail.ReadWrite for delegated and application access. See the Microsoft operation and permissions reference.

Mailbox selection: Authorization Code Flow uses /me and ignores userIdOrPrincipalName. Supplying another user does not redirect that call. Other authorization types use /users/{userIdOrPrincipalName}; their authentication must be valid for Microsoft Graph. Use Graph resource IDs rather than Salesforce record IDs.

Inputs

The table lists action labels, Apex field names, and data types. Provide one non-null request per invocation. Required text must not be blank.

InputApex fieldTypeRequiredDescription
User Id or Principal NameuserIdOrPrincipalNameStringUnless Authorization Code Flow is enabledUser id or user principal name. Required for application authorization; ignored for Authorization Code Flow.
Folder IdfolderIdStringYesFolder identifier.
Display NamedisplayNameStringYesFolder display name.

The invocable input has no connectorId field. Apex and Flow use CloudTools connector selection; the LWC controller accepts an additional connectorId property to select a record. This action does not resolve replacement tokens in its inputs; resolve dynamic values first. See Using Token Replacements.

Outputs

Returns a list containing one MSOutlookFolder, or an empty list if no response is mapped. Check the returned ID before subsequent operations.

OutputApex fieldTypeDescription
IdidStringFolder identifier.
Display NamedisplayNameStringFolder display name.
Parent Folder IdparentFolderIdStringParent folder identifier.
Child Folder CountchildFolderCountIntegerCount of child folders.
Unread Item CountunreadItemCountIntegerCount of unread messages.
Total Item CounttotalItemCountIntegerTotal count of messages.
Is HiddenisHiddenBooleanWhether folder is hidden.
OData TypeodataTypeStringOData type.
OData ETagodataEtagStringOData etag.
Additional PropertiesadditionalPropertiesList<DynamicObject>Additional data returned by query.

Optional properties depend on the response and any Select or Expand query. Do not treat an absent field as proof of its value. Timestamps represented by String remain text. Counts and metadata do not contain the full contents of the resource.

Use in Flow

Add MS Outlook – Folders – Update Folder in Flow Builder. Configure a Microsoft 365 application connector as the default for Flow automations, then populate the inputs above. Delegated connectors are not supported for CloudTools Flow automation. Add a fault path for callout errors. This implementation processes only the first input request; it is not a bulk action.

Use in custom Apex

This subscriber-org example uses the Apptigent namespace. Replace placeholders before use. Run in a context that permits callouts with a configured application connector. For an already-authorized delegated connector, omit the user value.

Apptigent.UpdateMSOutlookFolder.UpdateMSOutlookFolderInput request =
    new Apptigent.UpdateMSOutlookFolder.UpdateMSOutlookFolderInput();
request.userIdOrPrincipalName = 'REPLACE_WITH_MICROSOFT_USER_ID_OR_UPN';
request.folderId = 'REPLACE_WITH_FOLDER_ID';
request.displayName = 'Project Mail';

List<Apptigent.MSOutlookFolder> results =
    Apptigent.UpdateMSOutlookFolder.updateFolder(
        new List<Apptigent.UpdateMSOutlookFolder.UpdateMSOutlookFolderInput>{ request }
    );

Apptigent.MSOutlookFolder item = results.isEmpty() ? null : results[0];
String resultId = item == null ? null : item.id;
System.debug(resultId);

Submit one request per invocation. The example does not implement connector setup, delegated sign-in, or exception handling; those belong in the calling application.

Use in a Lightning Web Component

Use updateMSOutlookFolder from msOutlookConnectorLib, through MSOutlookConnectorController. This example uses repository c/ imports for a component in the same namespace. Replace placeholders and complete connector authorization before invoking it.

outlookActionExample.js

import { LightningElement } from 'lwc';
import { updateMSOutlookFolder, MSOutlookObjects } from 'c/msOutlookConnectorLib';

export default class OutlookActionExample 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 = MSOutlookObjects.inputs.folder();
            request.connectorId = this.connectorId;
            request.userIdOrPrincipalName = 'REPLACE_WITH_MICROSOFT_USER_ID_OR_UPN';
            request.folderId = 'REPLACE_WITH_FOLDER_ID';
            request.displayName = 'Project Mail';
            const result = await updateMSOutlookFolder(request);
            if (!result?.id) {
                throw new Error('No resource ID was returned.');
            }
            this.result = result;
            this.completed = true;
        } catch (error) {
            this.errorMessage = error.requiresInteractiveAuthorization
                ? 'Sign in to Microsoft for this connector, then try again.'
                : error.message || 'The Outlook action failed.';
        } finally {
            this.isRunning = false;
        }
    }
}

outlookActionExample.html

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

The library accepts one request object and resolves to one resource object, or null when no response is mapped; read result.id directly. The shared factory includes inputs for other actions; only the fields in this page and optional connectorId are used here.

The controller also exposes rawJson as a serialization of the mapped Apex result; it is not an original Microsoft response or an invocable Flow output.

This example reports authorization errors but does not implement sign-in. For delegated access, use getMSOutlookAuthorizationState, beginMSOutlookAuthorization, and createMSOutlookOAuthMessageHandler. Errors expose message and requiresInteractiveAuthorization.

The example prevents another invocation after success. Reset completed only when deliberately starting a new operation. If an error leaves the outcome uncertain, verify mailbox state before retrying; repeating the action can create duplicate mail, attachments, or folders, or act on an item that has already moved or been deleted.

Error handling and troubleshooting

SymptomWhat to check
Required fields errorPass a nonempty list with a non-null first request. Populate required resource fields and User Id or Principal Name for application authorization.
Authorization is requiredComplete or renew the current user’s delegated Microsoft authorization for the selected connector.
Access deniedCheck the operation permission, consent, connector identity, and mailbox access.
Resource not foundVerify IDs belong to the selected mailbox and refer to the expected resource. Authorization Code Flow ignores the user input.
Operation rejectedReview the Microsoft error and confirm the resource supports this operation.
Unexpected resultCheck for an empty Apex result, a null JavaScript response, omitted properties, or incomplete pagination. Handle exceptions in the caller.
Share this Doc

MS Outlook – Folders – Update Folder

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