0

We want to get the emails from the opportunity team and then populate them on custom object (I.e. Populating them in separate custom field fr each email id).

We have created a custom button on custom object (Child object of opportunity) by using vf page.

<apex:page standardController="Contracts__c">
<flow:interview name="Pre_Notification" finishLocation="/{!Contracts__c.Id}">
    <apex:param name="ContractsId" value="{!Contract_s__c.Id}"/>
</flow:interview>
</apex:page>

by passing the contracts id to flow, and based on some criteria we are sending alerts.

In addition to this we want to send the notifications to opportunity team as well. So we are planning to get the email ids of the opportunity team and populate them in custom email fields in contracts and these email fields can be used in email alerts.

Please let me know your thoughts on this...

2 Answers 2

1

Create a custom field at Contract object "Opportunity Team Mail Address (API name: OpportTeam_Mail_Address__c )".

Then with the help of below trigger on update of any contract, we will be able to tag the email address of the Account Team Member. Please find the Trigger below:

trigger TagOppTeamMemEmailAddress on Contract (Before Update) {
    Map<Id,Id> mapOfAccIdVsContrtId = new Map<Id,Id>();
    Set<Id> uniqAccIDSet = new Set<Id>();
    Set<Id> oppIdSet = new Set<Id>();
    Map<Id,Id> mapOfOppIdVsAccId = new Map<Id,Id>();
    Map<Id,String> mapOfOppIdvsEmailAdd = new Map<Id,String>();
    Map<Id,String> mapContactvsEmailToUdt = new Map<Id,String>(); 
    Set<ID> contrSet =  new Set<ID>();

if(Trigger.isBefore && Trigger.isUpdate){
    for(Contract cntr:Trigger.New){
        System.debug('@@@ cntr:'+cntr);
        if(cntr.AccountId != null){
            mapOfAccIdVsContrtId.put(cntr.AccountId,cntr.Id);
            uniqAccIDSet.add(cntr.AccountId);
        }
    }
    System.debug('@@@ mapOfAccIdVsContrtId:'+mapOfAccIdVsContrtId);
    if(!mapOfAccIdVsContrtId.isEmpty()){
        for(Opportunity opp:[SELECT Id,AccountId FROM Opportunity WHERE AccountId In:uniqAccIDSet]){
            oppIdSet.add(opp.Id);
            mapOfOppIdVsAccId .put(opp.Id,opp.AccountId);
        }
        if(oppIdSet.size() > 0){
            for(Opportunity_Team__c oppTeamMem :[SELECT Id,Email__c,Opportunity__c FROM Opportunity_Team__c WHERE Opportunity__c In:oppIdSet]){
                if(oppTeamMem.Email__c != null && oppTeamMem.Email__c != ''){
                    mapOfOppIdvsEmailAdd.put(oppTeamMem.Opportunity__c,oppTeamMem.Email__c);   
                }            
            }            
        }
        System.debug('@@@ mapOfOppIdvsEmailAdd:'+mapOfOppIdvsEmailAdd);

        if(!mapOfOppIdvsEmailAdd.isEmpty()){
            for(Id oppId : mapOfOppIdvsEmailAdd.Keyset()){
                if(mapOfAccIdVsContrtId.get(mapOfOppIdVsAccId.get(oppId)) != null){
                    mapContactvsEmailToUdt.put(mapOfAccIdVsContrtId.get(mapOfOppIdVsAccId.get(oppId)),mapOfOppIdvsEmailAdd.get(oppId));
                    contrSet.add(mapOfAccIdVsContrtId.get(mapOfOppIdVsAccId.get(oppId)));
                } 
            }                
        }          

        //Section where we are updating the email from Opp Team Mem
        if(!mapContactvsEmailToUdt.isEmpty()){
            for(Contract cntr:Trigger.New){
                cntr.OpportTeam_Mail_Address__c = mapContactvsEmailToUdt.get(cntr.Id);
            }           
        }
    }            

}

}

1
  • sorry to say we are trying with configuration only so...Please suggest with only configuration..i.e with flow or process etc.
    – Reddy
    Apr 18, 2017 at 9:08
0

Unfortunately, Visual Workflow can't perform a lookup on Account Team or Opportunity Team members. And Process Builder can't perform lookups.

I don't think there is a configuration-only solution to your requirements with Visual Workflow or Process Builder.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .