You need to sign in to do that
Don't have an account?

Hi I wrote a trigger to bring the account team member Userid to account...
Hi I wrote a trigger to bring the account team member Userid to account...The following trigger is updating the value to accoount object...which is fine ...but the problem is its is updating when i click on EDIT & then SAVE on account...Here i need that value is updated when i enter the ACcount team ...how it is possible?
trigger bringAccountTeamMember on Account (before insert, before update) {
set<ID> Accountids = new set<id>();
for (Account Acc : trigger.new) {
Accountids.add(Acc.id);
List<AccountTeamMember> AccTeam = [ select id,User.name from AccountTeamMember cm
where AccountID = :Accountids
order by User.name limit 1 ];
if (AccTeam.isEmpty() == false){
for (AccountTeamMember Accteams : AccTeam) {
Acc.Account_Team_Member__c = Accteams.User.name;
}
}
}
}
trigger bringAccountTeamMember on Account (before insert, before update) {
set<ID> Accountids = new set<id>();
for (Account Acc : trigger.new) {
Accountids.add(Acc.id);
List<AccountTeamMember> AccTeam = [ select id,User.name from AccountTeamMember cm
where AccountID = :Accountids
order by User.name limit 1 ];
if (AccTeam.isEmpty() == false){
for (AccountTeamMember Accteams : AccTeam) {
Acc.Account_Team_Member__c = Accteams.User.name;
}
}
}
}
As of now, Salesforce do not support triggers on AccountTeamMember object, an idea is in progress, hope salesforce gives it in its next release. Below is the idea, vote for it!
https://success.salesforce.com/ideaView?id=08730000000YR8IAAW
As a work around, you can create a visualforce page to add/display account team members, which can drive your logic. And instead of standard related list in the standard detail page layout, you can replace that with a visualforce snippet, though it looks ugly,thats the only option for now i believe!
Hope it helps:
Thanks,
Balaji