Re: Send list of opportunities with opportunity-specific info on each to sales owner

michaelstancil
Level 3

Send list of opportunities with opportunity-specific info on each to sales owner

Hi all,

 

I have a situation where I am sending emails to opportunities based on specific conditions, and then I need to notify the sales owner of the opportunity that the email has been sent with the opportunity-specific information. I've combed the forums and cobbled together something that finally sends, but does not print anything, even when it's replaced with a hardcoded sales owner email address that should deliver a result. The email of the sales owner is within the opportunity object, with two possible places of occuring.

 

This would be the email content of the notification email sent.

 

 

## Filter List
#set( $specificList = [] )
#foreach( $Opp in $OpportunityList )
#if( !$OpportunityList.Trigger.isEmpty() && $OpportunityList.PossibleSalesOwnerEmailOne == $lead.SalesOwnerEmailOne || !$OpportunityList.PossibleSalesOwnerEmailTwo == $lead.SalesOwnerEmailTwo )
#set( $void = $specificList.add($Opp) )
#end
#end

## Display List of Specific Items
#foreach( $Opp in $specificList )
Field1: ${OpportunityList.Field1}
Field2: ${OpportunityList.Field2}
Field3: ${OpportunityList.Field3}
</br>
#end

 

 

 

Tags (1)
7 REPLIES 7
SanfordWhiteman
Level 10 - Community Moderator

Re: Send list of opportunities with opportunity-specific info on each to sales owner

Hmm... you keep checking properties of the List itself, not the List item ($Opp), so that's never gonna match anything.

michaelstancil
Level 3

Re: Send list of opportunities with opportunity-specific info on each to sales owner

@SanfordWhiteman Ah - thanks for that. Though I did make that update to Opp from OpportunityList, but I'm still seeing no value. I looked at the raw output and it's empty as well. The token contents should be right underneath the first <br />

 

<div>
A new Sales Alert was sent.
<br />
<br />
<br />
</div>
</div>  

 

SanfordWhiteman
Level 10 - Community Moderator

Re: Send list of opportunities with opportunity-specific info on each to sales owner

That was only the first step, to make sure you were checking for properties in the right place. Tell me about your Opportunities -- what's this trigger property?

 

I would also be explicit about the condition here, and always use equals():

#if( !$OpportunityList.Trigger.isEmpty() && 
  ( $OpportunityList.PossibleSalesOwnerEmailOne.equals($lead.SalesOwnerEmailOne) ||     
    !$OpportunityList.PossibleSalesOwnerEmailTwo.equals($lead.SalesOwnerEmailTwo) ) 
)

 

michaelstancil
Level 3

Re: Send list of opportunities with opportunity-specific info on each to sales owner

@SanfordWhiteman I was just about to update that I'm an idiot and forgot to use the .equals and I forgot to print $specificList at the end.

 

The trigger property is a field that has the date and time of when we sent the email. If we didn't send the email, it will be empty, which is why I'm doing the is not empty check. 

 

For testing purposes, I've updated the code to as follows, which now outputs [] when I put the token in the email.

 

## Filter List
#set( $specificList = [] )
#foreach( $Opp in $OpportunityList )
#if( !$Opp.Trigger.isEmpty() && 
  ( $Opp.PossibleSalesOwnerEmailOne.equals("email@address.com") ||     
    $Opp.PossibleSalesOwnerEmailTwo.equals("email@address.com") ) 
)
#set( $void = $specificList.add($Opp) )
#end
#end

## Display List of Specific Items
#foreach( $Opp in $specificList )
Field1: ${Opp.Field1}
Field2: ${Opp.Field2}
Field3: ${Opp.Field3}
</br>
#end

$specificList

 

SanfordWhiteman
Level 10 - Community Moderator

Re: Send list of opportunities with opportunity-specific info on each to sales owner

Let's see a dump of the full $OpportunityList because without that, it’s hard to know whether your filters are correct.

michaelstancil
Level 3

Re: Send list of opportunities with opportunity-specific info on each to sales owner

@SanfordWhiteman So when I add $OpportunityList at the end it just shows $OpportunityList []

SanfordWhiteman
Level 10 - Community Moderator

Re: Send list of opportunities with opportunity-specific info on each to sales owner

That ain’t right. Did you check off the fields in the tree on the right-hand side, and are you testing with either a real email (not sample) or in Preview-by-List mode?