Get Current User Setting Timezone CRM C#
Views (7338)
Sometimes we need to get the current user timezone, so here is the code:
*You just need to pass the current CRM Service
Hope this helps.
Thanks.
public int? RetrieveCurrentUsersTimeZoneSettings(IOrganizationService service)
{
var currentUserSettings = service.RetrieveMultiple(
new QueryExpression("usersettings")
{
ColumnSet = new ColumnSet("localeid", "timezonecode"),
Criteria = new FilterExpression
{
Conditions =
{
new ConditionExpression("systemuserid", ConditionOperator.EqualUserId)
}
}
}).Entities[0].ToEntity<Entity>();
return (int?)currentUserSettings.Attributes["timezonecode"];
}
*You just need to pass the current CRM Service
Hope this helps.
Thanks.
This was originally posted here.

Like
Report
*This post is locked for comments