MS Entra – Users – Update User

Estimated reading: 5 minutes

MS Entra – Users – Update User

Update a user in Entra ID.

Action details

PropertyValue
Action labelMS Entra – Users – Update User
CategoryCloudTools
Apex class and methodUpdateEntraUser.updateUser
Input typeUpdateEntraUser.UpdateEntraUserInput
Output typeList<UpdateEntraUser.UpdateEntraUserOutput>
AuthorizationMicrosoft 365 connector; supported authorization depends on the endpoint and target.
Microsoft Graph requestPATCH /users/{userIdOrPrincipalName}

Prerequisites and permissions

Configure a CloudTools Connector with Connector Type set to Microsoft 365. Complete sign-in for OAuth Delegated (Authorization Code). For supported OAuth Application (Client Credentials) requests, grant application permissions and administrator consent. The identity must have access to the selected resource; directory operations can also require Microsoft Entra roles. Use Creating an Entra ID App and Integration Connectors for setup.

The action permission provider declares these alternatives. They are not cumulative requirements, not all are least privileged, and a scope can have target-specific restrictions. Check the Microsoft operation reference before selecting permissions.

Permission typeDeclared alternatives
DelegatedUser.ReadUpdate.All, User.ReadWrite.All, Directory.ReadWrite.All
ApplicationUser.ReadUpdate.All, User.ReadWrite.All, Directory.ReadWrite.All

Endpoints: /users/{id | userPrincipalName}

See the Microsoft operation and permissions reference.

Inputs

InputApex fieldTypeRequiredDescription
User Id or Principal NameuserIdOrPrincipalNameStringYesUser id or user principal name to update
Account EnabledaccountEnabledBooleanNoWhether the account is enabled
Display NamedisplayNameStringNoDisplay name for the user
Given NamegivenNameStringNoGiven name for the user
SurnamesurnameStringNoSurname for the user
Job TitlejobTitleStringNoJob title for the user
MailmailStringNoEmail address for the user
Mobile PhonemobilePhoneStringNoMobile phone number for the user
Office LocationofficeLocationStringNoOffice location for the user
Preferred LanguagepreferredLanguageStringNoPreferred language for the user
Usage LocationusageLocationStringNoTwo-letter country code for the user
DepartmentdepartmentStringNoDepartment for the user
Mail NicknamemailNicknameStringNoMail nickname for the user
Business PhonesbusinessPhonesStringNoComma-separated business phone numbers
Other MailsotherMailsStringNoComma-separated additional email addresses

Supply a nonempty list with a non-null first request. Graph actions process only that first request. Global inputs do not expose connectorId; subscriber Apex and Flow use CloudTools connector selection. Use Microsoft Graph resource IDs or the specifically documented user identifier, and resolve dynamic values before invocation.

Outputs

Returns one operation result after the call returns. Inspect success and message; an accepted or started operation may still require completion checks. Exceptions are generally thrown for failures rather than returned as success=false.

OutputApex fieldTypeDescription
SuccesssuccessBooleanWhether the update succeeded
MessagemessageStringResult message

Behavior and limits

Only documented writable inputs are sent. Blank optional strings are generally omitted rather than used to clear existing values; inspect the action body when a workflow needs explicit removal of a property.

Use in Flow

Use MS Entra – Users – Update User where supported. Use a Microsoft 365 application connector configured as Set as default for Flow automations only if the endpoint and target support application access. Supply required values, retain useful outputs, and add fault handling. Delegated connections are not supported for CloudTools Flow automation. The action processes only the first input request.

Use in custom Apex

This subscriber-org example uses the Apptigent namespace. Replace identifiers and example values before use. Configure the connector, complete authorization first, run in a context permitting callouts, and handle exceptions, empty results, and unmapped fields.

Apptigent.UpdateEntraUser.UpdateEntraUserInput request =
    new Apptigent.UpdateEntraUser.UpdateEntraUserInput();
request.userIdOrPrincipalName = '87d349ed-44d7-43e1-9a83-5f2406dee5bd';
request.displayName = 'Adele Vance';
request.jobTitle = 'Product Marketing Manager';
request.mobilePhone = '+1 425 555 0109';
request.officeLocation = '18/2111';
request.preferredLanguage = 'en-US';
request.businessPhones = '+1 425 555 0109';



List<Apptigent.UpdateEntraUser.UpdateEntraUserOutput> results =
    Apptigent.UpdateEntraUser.updateUser(
        new List<Apptigent.UpdateEntraUser.UpdateEntraUserInput>{ request }
    );
System.debug(results);

Use in a Lightning Web Component

Use updateEntraUser from msEntraConnectorLib through MSEntraConnectorController. These c/ imports apply in the same namespace. Set request.connectorId for direct MSEntraAction calls. The controller captures the request selection for MSEntraAction.

Global inputLWC request mapping
userIdOrPrincipalNamerequest.userIdOrPrincipalName
accountEnabledrequest.accountEnabled
displayNamerequest.displayName
givenNamerequest.givenName
surnamerequest.surname
jobTitlerequest.jobTitle
mailrequest.mail
mobilePhonerequest.mobilePhone
officeLocationrequest.officeLocation
preferredLanguagerequest.preferredLanguage
usageLocationrequest.usageLocation
departmentrequest.department
mailNicknamerequest.mailNickname
businessPhonesrequest.businessPhones (converted by the controller)
otherMailsrequest.otherMails (converted by the controller)

entraActionExample.js

import { LightningElement } from 'lwc';
import { updateEntraUser } from 'c/msEntraConnectorLib';

export default class EntraActionExample extends LightningElement {
    result = null;
    errorMessage = '';
    isRunning = false;
    completed = false;

    async handleRun() {
        if (this.isRunning || this.completed) return;
        this.isRunning = true;
        this.errorMessage = '';
        try {
            const request = { connectorId: 'REPLACE_WITH_CONNECTOR_RECORD_ID' };
            request.userIdOrPrincipalName = '87d349ed-44d7-43e1-9a83-5f2406dee5bd';
            request.displayName = 'Adele Vance';
            request.jobTitle = 'Product Marketing Manager';
            request.mobilePhone = '+1 425 555 0109';
            request.officeLocation = '18/2111';
            request.preferredLanguage = 'en-US';
            request.businessPhones = ['+1 425 555 0109'];
            this.result = await updateEntraUser(request);
            this.completed = true;
        } catch (error) {
            this.errorMessage = error.requiresInteractiveAuthorization
                ? 'Sign in to Microsoft for the connector, then try again.'
                : error.message || 'The Entra action failed.';
        } finally {
            this.isRunning = false;
        }
    }
}

entraActionExample.html

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

The library returns one mapped DTO or null. The controller can flatten nested fields, serialize data, or map an action result into an operation DTO. rawJson contains serialized mapped Apex data rather than the untouched Graph response.

Use getMSEntraAuthorizationState, beginMSEntraAuthorization, and createMSEntraOAuthMessageHandler to arrange delegated sign-in. The library normalizes errors but does not automatically sign in or retry. Reset completed for a new deliberate operation, and inspect resource state before retrying a mutation with an uncertain outcome.

Error handling and troubleshooting

SymptomWhat to check
Required fields errorSupply a nonempty request list and required or conditionally required inputs. For LWC, use the mapped field names.
Authorization or access deniedCheck connector selection, sign-in, endpoint/target permission support, administrator consent, directory roles, and resource access.
Resource not foundCheck Microsoft IDs and parent resource relationships. Preserve group/drive/item associations and mailbox/calendar/event IDs.
Missing or unexpected outputCheck query support, pagination, wrapper versus item models, public-only properties, and mapped DTO fields.
Operation rejectedInspect the Microsoft error, supported writable fields, group/calendar restrictions, recipient/license data, and file transfer limits.

See Entra connector introduction.

Share this Doc

MS Entra – Users – Update User

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