我有以下要求:
1) 获取其个人资料已更改的所有用户的列表。
2)然后查询FRUP(它是一个自定义对象)以检索与更改个人资料的用户关联的所有记录。(FRUP对象将包含所有用户在所有对象上创建的所有记录的列表说帐户,机会)
3) 更新 FRUP。
为了实现这一点,我编写了一个触发器,通过它我可以获取其个人资料已更改的所有用户的列表,如下所示:
Trigger UserProfileTrigger on User (before update) {
List<User> usr = new List<User>();
Map<String,String> userMap = new Map<String,String>();
for(User u: Trigger.new){
//Create an old and new map so that we can compare values
User oldOpp = Trigger.oldMap.get(u.ID);
User newOpp = Trigger.newMap.get(u.ID);
//Retrieve the old and new profile
string oldProfileId = oldOpp.profileId;
string newProfileId = newOpp.profileId;
//If the fields are different, the profile has changed
if(oldProfileId != newProfileId){
System.debug('Old:'+oldProfileId);
System.debug('New :'+newProfileId);
usr.add(u);
System.debug('User :'+usr);
}
}
}
以下是自定义对象 FRUP 上的字段:1)所有者 2)名称
3)记录 ID
4)文件夹 ID
5)创建者
6)最后修改者
任何帮助/建议?