SOLVED

Select specific opportunity (by type) and extract relative values

Go to solution
alexbodkin
Level 1

Select specific opportunity (by type) and extract relative values

I've spent the afternoon pouring through some discussion posts here trying to solve this myself, but I think I'm hitting the point where I'll benefit from just asking.

 

I'm trying to use dynamically insert data (the Service Start Date) from the Opportunity Object into the body of an email, however multiple Opps exist on these records so I'm trying to isolate a specific one -- by either the Opp Type (preferred) or Stage (backup if Type won't work). From what I've read, I believe I need to us a foreach to sort through the Opportunities, but my filter must be incorrect because it's disregarding the stage/type and still selecting the most recent Opp. 

 

Here's what I have: 

 

#set( $SSDate = "Unavailable" )
#foreach( $Opportunity in $OpportunityList )
#if( $Opportunity.Stage.equals("Closed Won") )
	#set( $SSDate = $OpportunityList.Service_Start_Date__c )
	#break
#end 
#end
${SSDate}

 

I'm a little new to VTL so I hope I've interpreted other posts correctly. Appreciate any direction! 

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Select specific opportunity (by type) and extract relative values

In line #4, why are you using $OpportunityList.Service_Start_Date__c? Shouldn't you be referencing the loop variable, i.e., $Opportunity for the value assignment instead of referencing the entire list object using $OpportunityList?

 

#set( $SSDate = "Unavailable" )
#foreach( $Opportunity in $OpportunityList )
#if( $Opportunity.Stage.equals("Closed Won") )
	#set( $SSDate = $Opportunity.Service_Start_Date__c )
	#break
#end 
#end
${SSDate}

 

 

View solution in original post

2 REPLIES 2
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Select specific opportunity (by type) and extract relative values

In line #4, why are you using $OpportunityList.Service_Start_Date__c? Shouldn't you be referencing the loop variable, i.e., $Opportunity for the value assignment instead of referencing the entire list object using $OpportunityList?

 

#set( $SSDate = "Unavailable" )
#foreach( $Opportunity in $OpportunityList )
#if( $Opportunity.Stage.equals("Closed Won") )
	#set( $SSDate = $Opportunity.Service_Start_Date__c )
	#break
#end 
#end
${SSDate}

 

 

alexbodkin
Level 1

Re: Select specific opportunity (by type) and extract relative values

Ah thank you so much!! I updated that to reference the loop variable, not the entire list, and it worked!