Saturday, 24 May 2014

public static int GetUserTimeZoneCode(ITracingService tracing, IOrganizationService service, IPluginExecutionContext context)
{
tracing.Trace("In GetUserTimeZoneCode method");
            int timeZoneCode = 0;

            try
            {
                string fetchXmls = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
                <entity name='usersettings'>
                    <attribute name='timezonecode' />
                    <link-entity name='systemuser' from='systemuserid' to='systemuserid' alias='ad'>
                        <filter type='and'>
                            <condition attribute='systemuserid' operator='eq' uitype='systemuser' value='{0}' />
                        </filter>
                    </link-entity>
                </entity>
            </fetch>";

                EntityCollection userSettings = service.RetrieveMultiple(new FetchExpression(string.Format(fetchXmls, context.UserId)));

               

No comments:

Post a Comment