function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sergey VolinetsSergey Volinets 

I can`t change User`s Time Zone by Apex trigger? Can`t set up picklist value properly.

I have read a apex trigger. This trigger must set change time zone of new user. But I recived error message, I don`t know what casuses the problem and how to do it properly.
My trigger:
trigger TimeZone on User (before insert) {
    for (User u : Trigger.new) {
        u.TimeZoneSidKey = '(GMT+02:00) Central European Summer Time (Europe/Paris)';
    }
}
Error:
User-added image

 
Best Answer chosen by Sergey Volinets
SandhyaSandhya (Salesforce Developers) 
Hi Sergey Volinets,

Please try below code I have tested it worked for me.
 
trigger TimeZone on User (Before insert) {
    for (User u : Trigger.new) {
        u.TimeZoneSidKey = 'Europe/Paris';
    }
}

Hope this helps you!

Please accept my solution as Best Answer if my reply was helpful. It will make it available for other as the proper solution. If you felt I went above and beyond, you can give me kudos.
 
Thanks and Regards
Sandhya