locked
User Options access in Dialog RRS feed

  • Question

  • I have a Dialog that runs against Contact records. I would like to determine the time zone of the User (the person running the Dialog), as we have users in several sites across the country.

    I know how to find the User's TZ by going to Settings --> Administration --> Users -->Specific User --> File --> Options --> General tab, but I don't know how to access this in a Dialog.

    Is this possible?


    Update:
    I tried to use {UTC Conversion Time Zone Code (Modified by (User))} in Form Assistant, but this came up blank; the Contact record's Modified By field did contain data.
    • Edited by MeProgrammer Tuesday, May 14, 2013 7:29 PM more info
    Tuesday, May 14, 2013 6:11 PM

Answers

  • You could try a custom workflow activity to return the user's time zone. One you have it you should then be able to use it in your dialog. 

    Sample: Retrieve Time Zone Information

    Sample: Update Next Birthday Using a Custom Workflow Activity

    Code to return the time zone friendly name would look something like this:

    private int? _timeZoneCode;
    
    private void RetrieveCurrentUsersSettings(IOrganizationService service)
    {
    	var currentUserSettings = service.RetrieveMultiple(
    		new QueryExpression(UserSettings.EntityLogicalName)
    		{
    			ColumnSet = new ColumnSet("localeid", "timezonecode"),
    			Criteria = new FilterExpression
    			{
    				Conditions =
    				{
    					new ConditionExpression("systemuserid", ConditionOperator.EqualUserId)
    				}
    			}
    		}).Entities[0].ToEntity<UserSettings>();
    
    	_timeZoneCode = currentUserSettings.TimeZoneCode;
    }
    
    private string RetrieveTimeZoneByCode(IOrganizationService service)
    {
    
    	var timeZoneDefinitions = service.RetrieveMultiple(
    		new QueryExpression(TimeZoneDefinition.EntityLogicalName)
    		{
    			ColumnSet = new ColumnSet("standardname", "timezonecode"),
    			Criteria = new FilterExpression
    			{
    				Conditions =
    				{
    					new ConditionExpression("timezonecode", ConditionOperator.Equal, _timeZoneCode)
    				}
    			}
    		}).Entities[0].ToEntity<TimeZoneDefinition>();
    
    	return timeZoneDefinitions.StandardName;
    }



    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn

    Wednesday, May 15, 2013 2:58 AM
    Moderator

All replies

  • You could try a custom workflow activity to return the user's time zone. One you have it you should then be able to use it in your dialog. 

    Sample: Retrieve Time Zone Information

    Sample: Update Next Birthday Using a Custom Workflow Activity

    Code to return the time zone friendly name would look something like this:

    private int? _timeZoneCode;
    
    private void RetrieveCurrentUsersSettings(IOrganizationService service)
    {
    	var currentUserSettings = service.RetrieveMultiple(
    		new QueryExpression(UserSettings.EntityLogicalName)
    		{
    			ColumnSet = new ColumnSet("localeid", "timezonecode"),
    			Criteria = new FilterExpression
    			{
    				Conditions =
    				{
    					new ConditionExpression("systemuserid", ConditionOperator.EqualUserId)
    				}
    			}
    		}).Entities[0].ToEntity<UserSettings>();
    
    	_timeZoneCode = currentUserSettings.TimeZoneCode;
    }
    
    private string RetrieveTimeZoneByCode(IOrganizationService service)
    {
    
    	var timeZoneDefinitions = service.RetrieveMultiple(
    		new QueryExpression(TimeZoneDefinition.EntityLogicalName)
    		{
    			ColumnSet = new ColumnSet("standardname", "timezonecode"),
    			Criteria = new FilterExpression
    			{
    				Conditions =
    				{
    					new ConditionExpression("timezonecode", ConditionOperator.Equal, _timeZoneCode)
    				}
    			}
    		}).Entities[0].ToEntity<TimeZoneDefinition>();
    
    	return timeZoneDefinitions.StandardName;
    }



    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn

    Wednesday, May 15, 2013 2:58 AM
    Moderator
  • Thanks, Jason! 

    That seems like a good, efficient way of accomplishing what I need. Thanks again for the help!

    Wednesday, May 15, 2013 1:11 PM