0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

カスタマーユーザがメールアドレス自分で変更した際、ユーザ名も同様に変わる処理

Last updated at Posted at 2022-11-13

画面からユーザオブジェクトの特定の項目を修正した時にトリガーが発火しないことがあるようです。これに該当するとApexでも処理できないかもしれません。

Updates to certain user fields do not fire a trigger on the User object
以下はRESTful APIでユーザ名を更新しようとしていますが、うまく行かなかったみたいです。

How to update User.username?

trigger UserTrigger on User (before update) {
    
    for(User newUser : Trigger.new){
        User oldUser = Trigger.oldMap.get(newUser.Id);
        if (oldUser != null && oldUser.Email != newUser.Email){
            newUser.Username = newUser.Email;
        }
    }

}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?