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
SF OperatorSF Operator 

lightningStylesheets not working

I migrated from classic to lightning, I want to maintain both. I'm adding lightningStylesheets=true to some vf pages that are not changing their style to lightning. It doesn't work with every page. Why?

VinayVinay (Salesforce Developers) 
Hi,

Hope below link gives you more information on 'Visualforce page does not always respect lightningStylesheets='true''

https://help.salesforce.com/articleView?id=000314958&language=en_US&type=1&mode=1

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar
SF OperatorSF Operator
Thanks for your reply, yes, I am able to set UserPreferencesLightningExperiencePreferred but I still have issues with some classic pages
VinayVinay (Salesforce Developers) 
Hi,

Can you check VF page version and try to upgrade to the latest.

Also, lightningStylesheets attribute isn’t supported in Communities.

Thanks,
Vinay Kumar
SF OperatorSF Operator

My VF page version is 48.0 and we are not using Communities.

I would love to know if there are another way to set UserPreferencesLightningExperiencePreferred.

Thank you for your fast reply.

 

 

VinayVinay (Salesforce Developers) 
You can use trigger to set UserPreferencesLightningExperiencePreferred.
 
trigger UserTrigger on User (before update) {
        for(User user : Trigger.new) {
			System.debug('Debug Log for User Preference'+user.UserPreferencesLightningExperiencePreferred);
				if(user.UserPreferencesLightningExperiencePreferred = false){
                user.UserPreferencesLightningExperiencePreferred = true;
                }
            }
}

Thanks,
Vinay Kumar
SF OperatorSF Operator
It's not working with that trigger
VinayVinay (Salesforce Developers) 
Do you see any error?

Check below example.

https://automationchampion.com/category/user-management/

Hope this will help.

Thanks,
Vinay Kumar