To update user personal settings in Dynamics 365 you have 2 opinions.
A) Using Power Automate, you'll need a flow that uses the Microsoft Dataverse connector to update the usersettings entity. Here's how you can build the flow:
Power Automate Flow to Update User Personal Settings
Step 1: Trigger the Flow
Trigger: Use the Manually trigger a flow action.
Step 2: Fetch the User's Settings
Action: Use the Dataverse: List rows action.
Table name: usersettings.
If you need all the rows then just add a simple fetch XML where get all the users or active users only.
If you want specific rows then use filter rows: systemuserid eq 'GUID' (replace 'GUID' with the dynamic value from the trigger input).
This will retrieve the usersettings record for the users.
Step 3: Update the User's Personal Settings
Action: Use the Dataverse: Update a row action.
Table name: usersettings.
Row ID: Add the usersettingsid from Step 2.
Update fields for example as:
timezonecode: Enter the time zone code from the trigger input.
uilanguageid: Enter the language code from the trigger input.
Add other fields as required (e.g., date formats, number formats, etc.).
Step 4: Notify Success (Optional)
Action: Add a Send an email (V2) or Post a message in a Teams channel action to notify administrators of the update.
Example: Update Time Zone and Language Code
Below is an example setup for inputs:
1. Trigger Inputs:
User GUID = 00000000-0000-0000-0000-000000000000
Time Zone Code = 190 (e.g., Pacific Standard Time)
Language Code = 1033 (e.g., English - United States)
2. Filter Row Query:
systemuserid eq '00000000-0000-0000-0000-000000000000'
3. Update Fields:
timezonecode = 190
uilanguageid = 1033
Testing the Flow
1. Trigger the flow manually, providing the necessary inputs.
2. Check if the user's personal settings are updated in Dynamics 365.
B) Using Console.
Here’s a console app in C# that uses the Dataverse Web API to update a user's personal settings in Dynamics 365.
C# Console Application to Update User Personal Settings
Prerequisites
1. Dynamics 365 SDK: Install the Microsoft.PowerPlatform.Dataverse.Client NuGet package.
2. Application Registration: Ensure the app has the necessary permissions (e.g., UserSettings.ReadWrite.All) in Azure AD.
Code
using Microsoft.PowerPlatform.Dataverse.Client;
using Microsoft.Xrm.Sdk;
using System;
class Program
{
static void Main(string[] args)
{
// Connection string for Dynamics 365
string connectionString = "AuthType=OAuth;Url=https://your-org.crm.dynamics.com;ClientId=your-client-id;ClientSecret=your-client-secret;RedirectUri=http://localhost;";
// Initialize ServiceClient
using (ServiceClient service = new ServiceClient(connectionString))
{
if (!service.IsReady)
{
Console.WriteLine("Failed to connect to Dynamics 365. Check your connection details.");
return;
}
Console.WriteLine("Connected to Dynamics 365!");
// User inputs
Console.Write("Enter the User GUID: ");
string userId = Console.ReadLine();
Console.Write("Enter Time Zone Code (e.g., 190 for PST): ");
int timeZoneCode = int.Parse(Console.ReadLine());
Console.Write("Enter Language Code (e.g., 1033 for English - US): ");
int languageCode = int.Parse(Console.ReadLine());
try
{
// Retrieve the User Settings record
var query = new QueryExpression("usersettings")
{
ColumnSet = new ColumnSet("usersettingsid"),
Criteria = new FilterExpression
{
Conditions =
{
new ConditionExpression("systemuserid", ConditionOperator.Equal, Guid.Parse(userId))
}
}
};
EntityCollection results = service.RetrieveMultiple(query);
if (results.Entities.Count == 0)
{
Console.WriteLine("User settings not found for the specified User GUID.");
return;
}
Entity userSettings = results.Entities[0];
// Update the user settings
userSettings["timezonecode"] = timeZoneCode;
userSettings["uilanguageid"] = languageCode;
service.Update(userSettings);
Console.WriteLine("User settings updated successfully!");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
}
Steps to Run
1. Replace your-org.crm.dynamics.com, your-client-id, and your-client-secret with your Dynamics 365 environment details.
2. Compile and run the console application.
3. Provide the User GUID, Time Zone Code, and Language Code when prompted.
Features
Flexible Input: You can specify the user and settings dynamically at runtime.
Error Handling: Ensures user settings exist before attempting updates.
Customizable: Extend the application to update additional fields as required.