Velocity script based on stage value in opportunity | Community
Skip to main content
New Participant
February 16, 2023
Solved

Velocity script based on stage value in opportunity

  • February 16, 2023
  • 1 reply
  • 2772 views

Hi There, 

I am trying to write a velocity script to pull data from opportunity list items, but I'm running into an issue when a record has more than one opportunity - the script isn't differentiating between opportunities even though I'm adding the opportunity stage as unique identifying criteria.

#if( $display.alt($OpportunityList.Stage.equals("Documents Collection")) ) #foreach( $oppty in $OpportunityList.Stage.equals("Documents Collection") ) #if ( $display.alt($oppty.Primary_Program__c.contains("Video Game Design and Animation"))) #if( !$display.alt($oppty.Government_Photo_ID_Received__c,"").isEmpty() ) Thank you for providing a valid Government Photo ID #end #if( !$display.alt($oppty.Status_In_Canada_Doc_Received__c,"").isEmpty() ) Thank you for providing valid proof of your status in Canada #end #if( !$display.alt($oppty.Letter_of_Intent_Received__c,"").isEmpty() ) Thank you for sending your Letter of Intent #end #if ( !$display.alt($oppty.All_Transcripts_Received__c ,"").isEmpty()) Thank you for providing Transcript #end #end #end #end

This is what I have. 

Can someone please tell me what I am missing?

 

Thanks in advance 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

This code can’t be doing what you intend.

 

You can’t loop over the Stage field of the OpportunityList. The OpportunityList is literally a list (ArrayList), it doesn’t have its own fields. You loop over the OpportunityList and which gives you a loop variable to work with.

 

The pattern is:

#foreach( $item in $someList ) ## work with $item #end

 

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
February 16, 2023

This code can’t be doing what you intend.

 

You can’t loop over the Stage field of the OpportunityList. The OpportunityList is literally a list (ArrayList), it doesn’t have its own fields. You loop over the OpportunityList and which gives you a loop variable to work with.

 

The pattern is:

#foreach( $item in $someList ) ## work with $item #end

 

aayushrorAuthor
New Participant
February 16, 2023

is there a way I can loop it only for items inside the opportunity list which has the stage value set to "Documents Collection" because we have different opportunity lists inside the same lead and the only thing which differs is "stage"

SanfordWhiteman
New Participant
February 16, 2023

is there a way I can loop it only for items inside the opportunity list which has the stage value set to "Documents Collection" because we have different opportunity lists inside the same lead and the only thing which differs is "stage"

You always loop over all the items: there’s no prefiltering on #foreach.

 

You wouldn’t have “different opportunity lists inside the same lead”. You have one OpportunityList per lead.

 

Inside the loop, you can check anything you want.

#foreach( $item in $someList ) #if( $item.someProperty.equals("some value") ) ## do something #else ## do something else #end #end