web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

Get Current User Setting Timezone CRM C#

Aileen Gusni Profile Picture Aileen Gusni 44,524
Sometimes we need to get the current user timezone, so here is the code:

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.

Comments

*This post is locked for comments