Another GDPR question - as part of our data retention policy, I'm required to build a process which marks users who haven't logged in for more than [X] years as inactive, and change their usernames and emails to "obfuscatedUser[autonumber}@mycompany.com".

Obviously this causes an issue for changing the email address - it requires confirmation from the new email address. However, if you're changing the address on an inactive user, and you're changing it to an email address that doesn't exist, you find yourself in a bit of a pickle.

There's the option of switching off verification altogether, but this is a whole lot of hoops to jump through and we do want to keep verification on in most cases.

Does anyone know of any alternatives? How are we going to manage GDPR Right-To-Be-Forgotten regulations if we can't obfuscate the email address of a customer who wants their details taken off our system?

  • I don't know about doing it automatically but there is a check box at the bottom of the user page that reads "Generate new password and notify user immediately". If you check that box when changing the email it is changed immediately without the need of a verification email.
    – gNerb
    Commented Sep 25, 2018 at 15:19
  • 2
    Maybe the obfuscate user method is something you could use? developer.salesforce.com/docs/atlas.en-us.apexcode.meta/…
    – Kasper
    Commented Sep 25, 2018 at 15:30
  • 3
    @Kasper You probably should have added that as an answer?
    – sfdcfox
    Commented Sep 25, 2018 at 15:50
  • Good point @sfdxfox, will do.
    – Kasper
    Commented Sep 25, 2018 at 16:02

1 Answer 1


In the summer '18 release a new method has been added to the UserManagement class that specifically deals with anonymising user information: obfuscateUser

obfuscateUser(userId, username)

Scrambles users’ data on their request when they no longer want their personal data recognized in Salesforce. When you invoke the method for the user, the data becomes anonymous, and you can never recover it. Use this method to set the username to a specific value after it’s scrambled.

To enable this feature, in Setup, go to User Management Settings, and select Scramble Specific Users’ Data.

You can find more information about this in the release notes

  • Yes. This is exactly what I'm looking for - I should have known that SF would have considered this. Nice one Kasper, thank you. Commented Sep 26, 2018 at 7:35

You must log in to answer this question.

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