Velocity Opportunity Sort Token | Community
Skip to main content
Barry_Moffat2
New Participant
April 7, 2020
Solved

Velocity Opportunity Sort Token

  • April 7, 2020
  • 3 replies
  • 5441 views

We have some emails where we use script tokens to sort the opportunities on a person's record by a datetime field and output a data value from the opportunity with the newest datetime in that specific field. However, we're finding that the tokens periodically fail, resulting in the email soft bouncing (the sender name and email address are two of the fields output by these tokens). 

However, when I look at the records on which they fail, the required sort fields are all present on the opportunity at the point that the email sends, so I'm at a loss as to why they fail. 

 

Has anyone encountered this? Attached example of the token script: 

 

#if( !$OpportunityList.isEmpty() ) #set( $OpportunityListRecentFirst = $sorter.sort($OpportunityList,["vu_vurpurpose:desc","vu_vurattached:desc"]) ) ${OpportunityListRecentFirst[0].rss_hbcemail} #end

 

 

All fields are checked on the token sidebar. The first datapoint is a string with only two possible values, and the second is the datetime field used to sort by most recent value. 

 

We use a Microsoft Dynamics CRM in case that's pertinent, with the dynamics stakeholder grid deployed so that multiple people can be associated with an individual opportunity

 

Any insights or suggestions would be much appreciated.   

 

 

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

Barry and I deciphered this offline, it was actually a question of unexpected null values (which had been thought impossible due to CRM-side rules when creating Opportunities).

3 replies

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
April 9, 2020

Barry and I deciphered this offline, it was actually a question of unexpected null values (which had been thought impossible due to CRM-side rules when creating Opportunities).

SanfordWhiteman
New Participant
April 7, 2020

However, we're finding that the tokens periodically fail, resulting in the email soft bouncing (the sender name and email address are two of the fields output by these tokens). 

Are you sure none of the fields (neither the fields you're sorting on, nor the field used for output) are null-able?

 

How are you verifying that "required sort fields are all present on the opportunity at the point that the email sends"? You'd have to send a real email (not sample) with the full $OpportunityList in the body (of course hard-coding the From:/Reply-To: info in this case to avoid the failure). What's the output then?

Barry_Moffat2
New Participant
April 7, 2020

They are null-able. I was verifying before by looking at the individual's activity log and reviewing the Update Opportunity activity that triggered the campaign (which has a log of all fields as they were at that moment I believe). 

 

I did what you suggested and dropped the full Opportunity List into an email (nice trick by the way) and all the opportunities in the list have values in those fields. It also outputted some other fields that we use in the email using similar script tokens (presumably because they were still in the text version?) 

SanfordWhiteman
New Participant
April 7, 2020

I did what you suggested and dropped the full Opportunity List into an email (nice trick by the way) and all the opportunities in the list have values in those fields. It also outputted some other fields that we use in the email using similar script tokens (presumably because they were still in the text version?) 


Any fields checked off in the tree will be included when you dump the whole list object.

 

So what output do you get — in the body here, so it doesn't stop the send — when you drop the logic to get the property off the most recent Oppty?

SanfordWhiteman
New Participant
April 7, 2020

Please highlight the code using the syntax highlighter so it's readable. Then we'll continue.

Barry_Moffat2
New Participant
April 7, 2020
#if( !$OpportunityList.isEmpty() ) #set( $OpportunityListRecentFirst = $sorter.sort($OpportunityList,["vu_vurpurpose:desc","vu_vurattached:desc"]) ) ${OpportunityListRecentFirst[0].rss_hbcemail} #end

Sorry, my bad. Thanks for taking a look, Sanford.

SanfordWhiteman
New Participant
April 7, 2020

Could you edit your initial post instead? B/c otherwise this keeps happening when people look at old posts.