6

I want to know if there is an easy way to restrict users from changing their Timezone. I wrote a trigger to do it for now, but I was wondering why Salesforce didnt allow us to write a Validation Rule on User's Timezone field. Any other ideas or ways please do let me know.

Thank you

4
  • I don't believe there is another way to do this. I would have done the same as you because of the limitations.
    – drakored
    Jun 10, 2013 at 19:55
  • I guess validation rules may not be allowed because Salesforce auto sets the Timezone to correct for Daylight Saving (DST)? Jun 10, 2013 at 20:18
  • 1
    Users would probably appreciate being able to change their time zone. Imagine a sales associate that flies across the country regularly and wants to see the dates and times in the system according to where they are physically. I'm not sure why you'd want to actually restrict this feature.
    – sfdcfox
    Jun 10, 2013 at 21:52
  • I think I will go with trigger approach, now that I know its not really possible without hack. The usecase is for call center users to transfer calls to next level (which has some rules). we wanted to keep it to EST for now. Jun 11, 2013 at 11:39

2 Answers 2

2

Trigger approach seems to be the best to restrict the users from changing their timezones.

 trigger UsertimezoneRestriction on User (before update) {
Profile p = [Select Id, Name from Profile where Name = 'Tier 1 Agent'];

for(User u : Trigger.new){
    if(u.ProfileId == p.Id && u.TimezoneSidKey != 'America/New_York'){
        u.addError('Cannot change the timezone');
    }
}

}

2
  • Could you please put some examples / links to your comment or describe it in more detail? Jun 11, 2013 at 12:17
  • I added the trigger code to my soln. Jun 11, 2013 at 21:16
0

If you install ObjectMetadataSnapshot, a freebie from Force.com Labs, you can create a validation rule on Time Zone that looks something like this:

$ObjectType.z_MetaDumpSetting__c.Fields.LastModifiedDate  <>  $Profile.LastModifiedDate

The above would restrict users from changing their time zone while allowing other fields to still be modified. I just verified the above in my Dev Org.

z_MetaDumpSetting__c represents the metadata value for the particular field, in this case, TimeZone. You'll see it in the drop-down when building the Work Rule as I did when I created the Rule before posting it here.

Description of ObjectMetadataSnapshot:

This 100% native Force App extracts object & field metadata information from your org and stores them as custom objects in same org. Once you complete to store metadata in custom objects, you can use Salesforce report to analyze DB schema or Salesforce Analytic Snapshots to manage DB schema version.

8
  • 2
    Not sure what "z_MetaDumpSetting__c" is? Anyways i will go with trigger approach. Jun 11, 2013 at 11:40
  • z_MetaDumpSetting__c represents the metadata value for the particular field, in this case, TimeZone. You'll see it in the drop-down when building the Work Rule just as I did when I created the Rule before posting it here. I'd hope you'd at least test it in your org before dismissing it and spending time building a trigger.
    – crmprogdev
    Jun 11, 2013 at 14:29
  • I didnt rule out your soln. I tried creating the Validation rule, using what you said in my sandbox, but I was not able to as I was not able to find z_MetaDumpSetting__c anywhere. As per my knowledge, anything that ends with __c is a custom object/field. Jun 11, 2013 at 21:14
  • The custom objects are automatically created when you select $ObjectType>SObjectField>LastModifiedDate when creating the Work Rule.
    – crmprogdev
    Jun 11, 2013 at 23:26
  • You must be dealing with something custom in your org because I don't see this field or any mention anywhere in google except here. Are you certain someone didn't add a custom object for Timezone in your org? Error: Field z_MetaDumpSetting__c.Fields.LastModifiedDate does not exist. Check spelling.
    – drakored
    Jun 12, 2013 at 0:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .