Skip to main content

Update User

Updates properties of an existing user in Azure Active Directory.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If ContinueOnError property is true, no error is caught when the project is executed even if Catch node is used.

Inputs

  • Access Id - The access ID from the Connect node. Optional if using direct credentials.
  • User Id - User ID (object ID) or user principal name (email) of the user to update.
  • Update Properties (JSON) - A JSON object containing the properties to update. This is configured in the node editor with C# syntax.

Commonly Updated Properties

{
"displayName": "John Doe",
"givenName": "John",
"surname": "Doe",
"jobTitle": "Senior Developer",
"department": "Engineering",
"officeLocation": "Building 2, Floor 3",
"mobilePhone": "+1 555 123 4567",
"businessPhones": ["+1 555 987 6543"],
"accountEnabled": true
}

Other Updatable Properties

  • usageLocation - Two-letter country code
  • streetAddress - Street address
  • city - City
  • state - State or province
  • postalCode - Postal code
  • country - Country
  • companyName - Company name
  • employeeId - Employee ID
  • mail - Email address (some restrictions apply)
note

You only need to include properties you want to update. Omitted properties remain unchanged.

Options

Direct Credentials (optional - alternative to using Connect node):

  • Tenant Id - Azure AD tenant ID (optional if using Access ID)
  • Client Id - Azure AD application client ID (optional if using Access ID)
  • Client Secret - Azure AD application client secret credential (optional if using Access ID)

Output

  • Result - Update result message, typically "Updated Successfully." if the operation succeeded.

How It Works

The Update User node:

  1. Authenticates using either the access ID or direct credentials
  2. Sends a PATCH request to Microsoft Graph API with the update properties
  3. Azure AD updates only the specified properties
  4. Returns a success message

Examples

Update User Job Title

Change a user's job title:

// Using Connect node
access_id = message.access_id
user_id = "john.doe@contoso.onmicrosoft.com"

// Update properties in node editor:
{
"jobTitle": "Lead Developer"
}

// Output
result = "Updated Successfully."

Update Multiple Properties

Update several user properties at once:

user_id = "john.doe@contoso.onmicrosoft.com"

// Update properties:
{
"jobTitle": "Senior Developer",
"department": "Engineering",
"officeLocation": "Building 3, Floor 2",
"mobilePhone": "+1 555 999 8888"
}

Disable User Account

Disable a user account (offboarding):

user_id = "departing.employee@contoso.onmicrosoft.com"

// Update properties:
{
"accountEnabled": false
}

console.log("User account disabled")

Enable User Account

Re-enable a disabled account:

user_id = "returning.employee@contoso.onmicrosoft.com"

// Update properties:
{
"accountEnabled": true
}

console.log("User account enabled")

Update User Location

Update location-related properties:

user_id = "relocated.employee@contoso.onmicrosoft.com"

// Update properties:
{
"officeLocation": "New York Office",
"city": "New York",
"state": "NY",
"country": "United States",
"usageLocation": "US"
}

Bulk User Updates

Update multiple users from a data source:

// User updates from CSV or Excel
updates = [
{email: "user1@contoso.onmicrosoft.com", title: "Manager"},
{email: "user2@contoso.onmicrosoft.com", title: "Director"},
{email: "user3@contoso.onmicrosoft.com", title: "VP"}
]

// Loop through updates
for (update of updates) {
try {
// Update User node
// User Id: update.email
// Properties:
{
"jobTitle": update.title
}

console.log("Updated: " + update.email)

// Delay between updates
// Wait 0.5 seconds

} catch (error) {
console.log("Failed to update: " + update.email)
}
}

Sync HR Data to Azure AD

Update users based on HR system data:

// HR data
hr_updates = [
{
email: "john.doe@contoso.onmicrosoft.com",
department: "Engineering",
title: "Senior Developer",
phone: "+1 555 111 2222",
office: "Building 2"
}
]

// Process each update
for (hr_data of hr_updates) {
// Update User node
// User Id: hr_data.email
// Properties:
{
"department": hr_data.department,
"jobTitle": hr_data.title,
"mobilePhone": hr_data.phone,
"officeLocation": hr_data.office
}

console.log("Synced HR data for: " + hr_data.email)
}

Update Contact Information

Update phone and address:

user_id = "john.doe@contoso.onmicrosoft.com"

// Update properties:
{
"mobilePhone": "+1 555 123 4567",
"businessPhones": ["+1 555 987 6543", "+1 555 111 2222"],
"streetAddress": "123 Main St",
"city": "Seattle",
"state": "WA",
"postalCode": "98101"
}

Conditional Update

Update only if certain conditions are met:

user_id = "john.doe@contoso.onmicrosoft.com"

// Get User node first
// User Id: user_id

// Check condition
if (result.department === "Sales") {
// Update User node
// User Id: user_id
// Properties:
{
"jobTitle": "Sales Representative",
"officeLocation": "Sales Floor"
}

console.log("Updated sales user")
}

Tips for Effective Use

  • Partial updates: Only include properties you want to change
  • Validation: Validate data before updating
  • Error handling: Use Try-Catch for bulk updates
  • Logging: Log all update operations for audit trails
  • Null values: To clear a property, set it to null
  • Phone format: Use international format for phone numbers
  • Usage location: Set usageLocation for license assignment
  • Bulk updates: Add delays to avoid throttling

Common Errors and Solutions

"User Id cannot be empty"

Cause: The User Id input was not provided.

Solution: Provide a valid user ID or user principal name:

user_id = "john.doe@contoso.onmicrosoft.com"

"Response Status is not OK - User not found"

Cause: No user exists with the specified ID.

Solution:

  • Verify the user ID or email is correct
  • Use Get User to verify user exists

"Property cannot be updated"

Cause: Some properties are read-only or require special permissions.

Solution:

  • Check which properties are updatable in Microsoft Graph documentation
  • Verify your application has appropriate permissions
  • Some properties like userPrincipalName have restrictions

"Either Client Secret with Tenant ID and Client ID, or Access ID must be provided"

Cause: Neither access ID nor complete credentials were provided.

Solution:

// Option 1: Use Connect node
access_id = message.access_id

// Option 2: Provide all credentials
tenant_id = "your-tenant-id"
client_id = "your-client-id"
// Set Client Secret option from vault

Invalid Property Value

Cause: Property value doesn't meet format requirements.

Solution: Ensure proper formatting:

// Correct formats
"mobilePhone": "+1 555 123 4567" // International format
"usageLocation": "US" // Two-letter code
"accountEnabled": true // Boolean, not string

Best Practices

  1. Verify first: Get user information before updating to verify they exist
  2. Partial updates: Only update properties that need changing
  3. Validation: Validate all input data before updating
  4. Error handling: Always use Try-Catch for update operations
  5. Logging: Log all updates with timestamps and changed properties
  6. Bulk operations: Add delays between updates to avoid throttling
  7. Null safety: Check data exists before using it in updates
  8. Audit trail: Maintain records of what was changed and when
  9. Testing: Test updates in development before production
  10. Rollback plan: Have a process to revert changes if needed