You need to sign in to do that
Don't have an account?
SF Operator
Unable to set UserPreferencesLightningExperiencePreferred
I'm ussing a trigger to set that:
trigger SetUserPreferencesLightning on User (before insert, before update) {
string url = Apexpages.currentPage().getUrl();
for(User user : Trigger.new) {
if(url.contains('lightning')){
user.UserPreferencesLightningExperiencePreferred = true;
}
}
}
This works for my admin profile but is not working for another users. (those users are not switched to lightning as default page but they can switch to lightning)
Anudeep (Salesforce Developers)
I would recommend the following instead of if(url.contains('lightning'))
SF Operator
Thanks for your fast reply, I tried that way and the problem is when they switch back to classic and then switch to lightning, the UserPreferencesLightningExperiencePreferred stays at false.