+ Start a Discussion
RobinCRobinC 

Account Trigger on Account Contact Role Change

Is there a way to write a trigger that will fire when an AccountContactRole is added or deleted to/from an account? According to the documentation, the Account Trigger does not fire for related child objects, which means that there is no way to update information from the assignment of a given role back up to the parent account until the user edits the account.

 

Any Ideas?


Thanks,


Robin

cashworthcashworth

You could try creating a trigger that fires on the AccountContactRole object after insert. It could then query the account, query AccountContactRoles on the account and then update a field on the account with the list size from the Account ContactRole query (kinda like a summary roll-up field would do). Once the DML operation takes place from your trigger to update the account that could cause another trigger to fire on the account (before or after update).

 

Not the cleanest solution in the world but I have done a few of these in the past with the Contract Object where you cannot do summary roll-ups to the account.

RobinCRobinC

Kind of a newbie question, but the UI does not seem to allow triggers on the AccountContactRole object:

 

Error: Compile Error: SObject type does not allow triggers: AccountContactRole at line 1 column 31

 

How do you go about creating a trigger on that object?

 

Thanks,

 

Robin

cashworthcashworth

That's a bit of a problem then... I was not aware that the AccountContactRole would not allow triggers. You also cannot do a roll-up summary field on the Account to get a count of them... 

 

I have created several custom objects in the past to mitigate this sort of issue. May be a lot more work but this is about the inly thing I can suggest since Salesforce has the standard object locked up...

crop1645crop1645

there is an interesting discussion of this problem here: http://groups.google.com/group/npsf/browse_thread/thread/93dc1a3d29ccd80d

RobinCRobinC

Thanks - certainly seems convoluted.

 

Is there any movement by the SalesForce.com team to simply expose/add trigger events on the standard child objects like AccountContactRole or OpportunityContactRole?

 

Based on searching around on the boards and other groups, that it would be highly beneficial to a number of people and would eliminate a whole bunch of workarounds and hoops that people are jumping through to get the functionality.

 

These child records are discrete database ojects so it would appear to be a fairly small amount of work on the core engine vs. a LOT of work by the end users to work around the deficiency...

 

Robin

Joe DeTolve 11Joe DeTolve 11
7 years and still waiting......