Velocity Script- How do I get the data from most recent SFDC Custom Object record?
Hi there,
I am trying to get various Velocity script to fetch data from a Subscription SFDC Custom Object and I wanted to ask help in understanding how do I make sure that I am selecting the relevant Subscription record. I am trying to only select the records whose subscription is ending in the next 3 months.
Thus, I wanted to check if there is a way in VTL to filter/constraint certain conditions? So the script always picks up the relevant data. ?
Example Script:
##Fetch Subscription Data from SFDC Custom object
#set($SubscriptionName = ${Subscription__cList.get(0).Name})
#set($SubscriptionStatus = ${Subscription__cList.get(0).Subscription_Status__c})
#set($AutoRenew = ${Subscription__cList.get(0).AutoRenew__c})
#set($NextRenewalDate = ${Subscription__cList.get(0).NextRenewalDate__c})
##Conditions
#if (($SubscriptionStatus == "Active") && ($AutoRenew == "true"))
${SubscriptionName}
#else
Test Fallback Name
#end
With this script where there are multiple subscription records, the script is picking up the oldest record always and the fallback sentence is displayed.
Please let me know if you know how I can select the right record to fetch data from?
Thanks