Skip to main content
Level 1
Mar 10, 2023 10:29 PM UTC
Solved

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! 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Darshil_Shah1
Darshil_Shah1Accepted solution
Adobe Champion, Community Advisor, UG Leader
Mar 11, 2023 4:58 AM UTC

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}

 

 

2 replies

Darshil_Shah1
Adobe Champion, Community Advisor, UG Leader
Darshil_Shah1Adobe Champion, Community Advisor, UG LeaderAccepted solution
Adobe Champion, Community Advisor, UG Leader
Mar 11, 2023 4:58 AM UTC

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}

 

 

Translate
Level 1
Mar 13, 2023 4:07 PM UTC

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

Translate