AnsweredAssumed Answered

Script Token - Sorting Opportunities

Question asked by Robert Whited on Jun 7, 2019
Latest reply on Jun 7, 2019 by Sanford Whiteman

I am new to using script tokens in Marketo so please excuse my ignorance...

I am trying to create a script token that pulls a field value on the Opportunity Object. This field represents a customer's Line of Credit balance remaining, LOC__c. The screenshot below shows the script when I drag.



A person will have one or more Opportunities, but only one in the list will have a Line of Credit balance remaining. The others will not have a value for LOC__c.


When I attempt to sort the list of Opportunities by LOC__c by the highest value first, the script only works when a person has 1 Opportunity:


#if( $OpportunityList && $OpportunityList.size() > 0 )

#set( $OpportunityListHighestFirst = $sorter.sort($OpportunityList,["LOC__c:desc"]) )





Any assistance would be welcomed!