1

I have another situation that I need to write a trigger for and I am wondering if there is an out of the box solution I can use.

Basically when a team member is added or deleted from an Opportunity team, I need to send an email notification to that team member and the whole Opportunity team. So far I am not come across any method of doing this without code. Can you please tell me if there is a way to do this without a trigger. Thank you.

1

Triggers, triggers all the way I'm afraid...

I think it fails into category of "junction objects" (between User and Opportunity) and docs say email alerts aren't supported on junction objects.

Workflows don't work on OpportunityTeamMember (the option is both inaccessible from GUI as well as forced creation of OpportunityTeamMember.workflow file fails in Eclipse).

<?xml version="1.0" encoding="UTF-8"?>
<Workflow xmlns="http://soap.sforce.com/2006/04/metadata">
    <alerts>
        <fullName>Team_Modified</fullName>
        <description>Team Modified Notification</description>
        <protected>false</protected>
        <recipients>
            <type>creator</type>
        </recipients>
        <senderType>CurrentUser</senderType>
        <template>unfiled$public/Case_Modified</template>
    </alerts>
    <rules>
        <fullName>Team Modified</fullName>
        <formula>true</formula>
        <actions>
            <name>Team_Modified</name>
            <type>Alert</type>
        </actions>
        <active>true</active>
        <description>Hi StackExchange!</description>
        <triggerType>onCreateOrTriggeringUpdate</triggerType>
    </rules>
</Workflow>

renders

Save error: OpportunityTeamMember.Team Modified : Cannot create a workflow rule on entity:OpportunityTeamMember
Save error: OpportunityTeamMember.Team_Modified : Cannot create a workflow action on entity:OpportunityTeamMember

Same story with AccountContactRole, AccountPartner, OpportunityContactRole etc. - several objects where we can't add fields, customize them (well, except the Role picklist but you get the idea)...

Bonus - looks like mailing Opp Team members is clunky in general ;)

  • Thank you. Kind of expected this but I suppose SF may provide something in upcoming versions. – Richard N Dec 3 '12 at 20:11
  • Also do you know how I can send am email to all members of an Opportunity team in Apex? I just need to know how I can obtain their emails. – Richard N Dec 3 '12 at 21:38
  • SELECT User.Email FROM OpportunityTeamMember WHERE OpportunityId = :oppId AND User.isActive = true. Adapt as you see fit to include an IN clause. Or maybe even subquery would be easiest method of "bulkifying": SELECT Id, (SELECT User.Email FROM OpportunityTeamMembers WHERE User.IsActive = true) FROM Opportunity WHERE Id IN :changedOppsIds (you'd have to build a set of Opportunity Ids first) – eyescream Dec 3 '12 at 21:52
  • Thanks. Since I am using this inside a for loop in a trigger, I was hoping to avoid SOQL. Will open a new question with my code. Please do see it. – Richard N Dec 3 '12 at 22:32
  • Check salesforce.stackexchange.com/q/4970/799 before actually posting :) should give you hints how to collect all Opp Ids that have to be checked, run only 1 query, then in final loop use the queried data. – eyescream Dec 3 '12 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.