Skip to main content
Level 2
Feb 16, 2023 3:20 PM UTC
Solved

Velocity script based on stage value in opportunity

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.
SanfordWhiteman
SanfordWhitemanAccepted solution
User Group Leader
Feb 16, 2023 6:42 PM UTC

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

 

8 replies

SanfordWhiteman
User Group Leader
SanfordWhitemanUser Group LeaderAccepted solution
User Group Leader
Feb 16, 2023 6:42 PM UTC

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

 

Translate
aayushrorAuthor
Level 2
Feb 16, 2023 7:07 PM UTC

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"

Translate
SanfordWhiteman
User Group Leader
User Group Leader
Feb 16, 2023 8:35 PM UTC

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

 

Translate