SOLVED

Velocity Opportunity Sort Token

Go to solution
Highlighted

Re: Velocity Opportunity Sort Token

Thanks Sanford. If you don't mind, I'll send you a DM  with the full dump as it contains customer information. Reviewing it again though, the specific opportunity that triggered the email (and should have had the most recent datetime field for the sort) is missing from the list. That doesn't really explain why it didn't just output the most recent one actually present on the list though. 

 

I've encountered opportunity to person  associations breaking very occasionally on one of our other instances, but that instance has a custom built API-driven data sync, rather than the native CRM bi-directional sync we use in this case. Up until now, have never encountered oppty associations failing in this one.   

 

Thanks for your help, 

Highlighted
Level 10 - Community Moderator

Re: Velocity Opportunity Sort Token

In your last snippet, you're trying to sort on the property vu_opportunitycreated, but that doesn't appear at all in the $OpportunityList dump you PM'd me.

 

However, a completely absent property would be ignored from the sort (as opposed to if it were sometimes null, which definitely is not ignored). So that wouldn't on its own explain the behavior, but it is confusing!

 

To round up the findings: you're still seeing no output when you try to output the entire sorted list, $OpportunityListRecentFirst, but in that same email, $OpportunityList dumps as expected (and is the same as what you PM'd)?

 

 

Highlighted

Re: Velocity Opportunity Sort Token

So sorry Sanford, that last snippet was a red-herring. I had been messing with a test token to see if other sort fields made a difference and I added that vu_opportunitycreated field - forgot to remove it again before posting. That said, now that I've removed that extra sort field, it's back to the below and still outputs nothing for that specific person, while the simple $opportunitylist token does. The one below does output the sorted list for other people though, so is the issue likely to be related to the opportunity role/association breaking at least intermittently on some person records , rather than a failure of the velocity script itself?     

#if( !$OpportunityList.isEmpty() )



#set( $OpportunityListRecentFirst = $sorter.sort($OpportunityList,["vu_vurpurpose:desc","vu_vurattached:desc"]) )
$OpportunityListRecentFirst
#end

  

Thanks again, Barry

 

 

Highlighted
Level 10 - Community Moderator

Re: Velocity Opportunity Sort Token


likely to be related to the opportunity role/association breaking at least intermittently on some person records , rather than a failure of the velocity script itself?     

I don't think that's it. You can see the list exists, so it is otherwise accessible in Velocity. Something is up with the specific list for that lead.  Please PM me the output of this code for that lead:

 

#foreach( $oppty in $OpportunityList )
#foreach( $entry in $oppty.entrySet() )
$entry.getKey() = $entry.getValue().class $entry.getValue()
#end
#end

 

Highlighted

Re: Velocity Opportunity Sort Token

Thanks Sanford, shot you a PM with the output.

Highlighted
Level 10 - Community Moderator

Re: Velocity Opportunity Sort Token

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).

View solution in original post