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
Jaswinder Singh Sidhu 6Jaswinder Singh Sidhu 6 

can we write trigger on User object which fires whenever we login salesforce??

NagendraNagendra (Salesforce Developers) 
Hi Jaswinder,

For this, you can create an Apex class that gets executed once a day and dumps the LastLoginDate date field from the user and places it into a custom object.

You can create triggers on the User object but the firing is odd, to say the least...Although you can write triggers on the User object it is still pretty restrictive in what you can do.

Note: Always it's recommended that you write before triggers on the user object rather than after triggers.

Hope this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra
Sujeet PatelSujeet Patel
Hi Jaswinder
as you asked trigger will not fire brother.
trigger only fire when we perform any CRUD(Create,retrieve,Update and Delete) on Perticular Record.
But in your case we will login and then fire this is not possible brother.