hello, i need to create a plugin to update a new user -timezone immediately after it created, but i don't know how to update the timezone in the connected usersettings - which attributes (like TimeZoneCode) do i must change if i always want to change to time zone to the my country- paris? , and how to update? **my steps:
- i create a post operation plugin, on systemuser entity - create
- get the id of the new systemuser // systemUser.systemuserid;
- retrieve its connected userSettings according to the systemuser id
ColumnSet attributes = new ColumnSet(new string[] { "timezonecode" }); var userSettingsResult = _service.Retrieve(userSettings.LogicalName, newSystemUserId, attributes);
**4. but i dont know which attributtes i need to update in usersettings to change the genereal time zone
for example: from london to my country paris ( i always change to paris)
do i only need to change the TimeZoneCode or i need to change more attributes like TimeZoneBias? and if so which attributes and and how?**
my code
public void updateNewUserTimeZone(MOHServiceContext myContext, Entity entity, ITracingService trc, IOrganizationService service, IPluginExecutionContext executionContext)
{
if (entity != null)
{
// post operation - the new system user
var systemUser = entity.ToEntity<systemuser>();
var newSystemUserId=systemUser.systemuserid; //get the id of the new systemuser
if (newSystemUserId)
{
//find the userSettingObject that has the same id as the system user now created
--var userSettingsResult = (from userSettingObject in myContext.userSettingsSet
--where userSettingObject.systemuserid == newSystemUserId
--select userSettingObject).FirstOrDefault();
// second way to retrive user setting
//the fields we wandt to retrive from usersettings
ColumnSet attributes = new ColumnSet(new string[] { "timezonecode" });
// Retrieve the usersettings and its timezonecode attribute.
var userSettingsResult = _service.Retrieve(userSettings.LogicalName, newSystemUserId, attributes);
//if we find serSettingObject that has the same id as the system user now created
if (userSettingsResult != null)
{
//how to update the time zone in userSettingsResult we found to paris?
}
}
}
thanks a lot :) li