SOLVED

Help with Velocity Scripting

Go to solution
ckowalczyk
Level 2

Re: Help with Velocity Scripting

so like this?

 

#set($totalCalled = $math.toNumber($License_Group__c.Total_Called_in_last_30_days__c))
#set($numberOfPaidLicenses = $math.toNumber($License_Group__c.Number_of_Paid_Licenses__c))
#set($numberOfUnpaidLicenses = $math.toNumber($License_Group__c.Number_of_Unpaid_Licenses__c))
#set($totalLicenses = $totalCalled - $numberOfPaidLicenses - $numberOfUnpaidLicenses)

Total Licenses: $totalLicenses

${License_Group__cList.get(0).Number_of_Paid_Licenses__c}
${License_Group__cList.get(0).Number_of_Unpaid_Licenses__c}
${License_Group__cList.get(0).Total_Called_In_Last_30_Days__c}

#foreach( $License_Group__c in $License_Group__cList )
## $License_Group__c is set to each object in the list in turn
#end

 

or is it like this:

#set($totalCalled = $math.toNumber($License_Group__c.Total_Called_in_last_30_days__c))
#set($numberOfPaidLicenses = $math.toNumber($License_Group__c.Number_of_Paid_Licenses__c))
#set($numberOfUnpaidLicenses = $math.toNumber($License_Group__c.Number_of_Unpaid_Licenses__c))
#set($totalLicenses = $totalCalled - $numberOfPaidLicenses - $numberOfUnpaidLicenses)

Total Licenses: $totalLicenses

#foreach${License_Group__cList.get(0).Number_of_Paid_Licenses__c}
#foreach${License_Group__cList.get(0).Number_of_Unpaid_Licenses__c}
#foreach${License_Group__cList.get(0).Total_Called_In_Last_30_Days__c}

#foreach( $License_Group__c in $License_Group__cList )
## $License_Group__c is set to each object in the list in turn
#end



Or something like this:

#set($totalCalled = $math.toNumber(#foreach$ $License_Group__c.Total_Called_in_last_30_days__c))
#set($numberOfPaidLicenses = $math.toNumber(#foreach$ $License_Group__c.Number_of_Paid_Licenses__c))
#set($numberOfUnpaidLicenses = $math.toNumber(#foreach$ $License_Group__c.Number_of_Unpaid_Licenses__c))
#set($totalLicenses = $totalCalled - $numberOfPaidLicenses - $numberOfUnpaidLicenses)

Total Licenses: $totalLicenses

#foreach( $License_Group__c in $License_Group__cList )
## $License_Group__c is set to each object in the list in turn
#end
SanfordWhiteman
Level 10 - Community Moderator

Re: Help with Velocity Scripting

None of those. You only work with $License_Group__c inside the loop, otherwise it does not exist in the Velocity context and will be null.

 

So closest to the 3rd one, but any reference to $License_Group__c inside the #foreach.

 

(Honestly not even sure where you’d get the idea $License_Group__c could be used. That’s not a variable Marketo declares for you. Only the list is declared.)

ckowalczyk
Level 2

Re: Help with Velocity Scripting

I think we're good to go!

Thanks so much for your help @SanfordWhiteman !