I have requirement to update user record based on insert/update Junction object between custom object and user. I need to update user custom field accountdef with junction object values(more than one for given user).I am newbie to Apex coding and having trouble with bulkifying the code. I have started something like this but could not navigate list to update user record.Any help will be appreciated.
trigger UpdateUserGUL on GUL_Account_to_User_Junction__c (after insert) {
set<id> UserList = new Set<id>();
for (GUL_Account_to_User_Junction__c junc : Trigger.New){
//add set of Ids
userList.add(junc.UserId__c);
}
//query junction records based on userid set
GUL_Account_to_User_Junction__c[] juncrecords = [select id,UserId__c,GUL_Account_Name__c,Chatter_Group_Name__c
from GUL_Account_to_User_Junction__c where UserId__c IN :UserList];
Map<id, String> AccountsMap = new Map<id, String>();
Map<id, String> ChatterMap = new Map<id, String>();
//Create Map of records
for (GUL_Account_to_User_Junction__c j : juncrecords) {
AccountsMap.put(j.UserId__c, j.GUL_Account_Name__c);
ChatterMap.put(j.UserId__c, j.Chatter_Group_Name__c);
}