openmrs-esm-core

O3 Framework / setUserProperties

Function: setUserProperties()

setUserProperties(userUuid, userProperties, abortController?): Promise<SessionStore>

Defined in: packages/framework/esm-api/src/current-user.ts:387

Updates the user properties for a specific user. User properties are key-value pairs that store user-specific settings and preferences. After updating the properties on the server, the current user session is refetched to reflect the changes.

Parameters

userUuid

string

The UUID of the user whose properties should be updated.

userProperties

An object containing the properties to set or update.

abortController?

AbortController

Optional AbortController to allow cancellation of the request. If not provided, a new AbortController is created.

Returns

Promise<SessionStore>

A Promise that resolves with the updated SessionStore after refetching the current user.

Example

import { getLoggedInUser, setUserProperties } from '@openmrs/esm-api';
const user = await getLoggedInUser();
await setUserProperties(user.uuid, {
  defaultLocale: 'en_GB',
  customSetting: 'value'
});