SOLVED

Velocity Script- Addition of float field in MKTO custom Objects

Go to solution
Malay_Chakrabo1
Level 2

Velocity Script- Addition of float field in MKTO custom Objects

Hola Marketo community ðŸ‘‹

 

I had some questions on addition using velocity scripting. We're trying to send out invoices via the Marketo emails and are pushing the invoicing data in Marketo custom objects through our Datawarehouse. 

 

Thus, I wanted to understand if any accounts have multiple invoices they will be created as multiple custom object records in Marketo. So I am trying to see if we can make additions on multiple MKTO custom object records if the records match certain criteria. 

 

Please see below the script we have come up with: 

 

#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/Denver") )
#set( $defaultLocale = $date.getLocale() )
#set( $calNow = $date.getCalendar() )
#set( $ret = $calNow.setTimeZone($defaultTimeZone) )
#set( $calConst = $field.in($calNow) )

##Set Subscription Details via the MKTO Custom Object 

#set( $renewDate = $convert.parseDate(${renewalObject_cList.get(0).subscriptionEndDate},'yyyy-MM-dd') ) 
#set( $renewSubDate = $convert.toCalendar($renewDate) )
#set( $ISO8601DateOnly = "yyyy-MM-dd" )
#set( $ISO8601DateTime = "yyyy-MM-dd'T'HH:mm:ss" )
#set( $ISO8601DateTimeWithSpace = "yyyy-MM-dd HH:mm:ss" )
#set( $ISO8601DateTimeWithMillisUTC = "yyyy-MM-dd'T'HH:mm:ss.SSSZ" )

##Set Subscription Name, Status, AutoRenew via the Renewal Custom Object 
#set( $Subscription =  ${renewalObject_cList.get(0).subscriptionName} )
#set( $Status = ${renewalObject_cList.get(0).subscriptionStatus})
#set( $AutoRenew = ${renewalObject_cList.get(0).autoRenew})

##Set Invoice MRR via the Renewal INVOICE Object 
#set( $InvoiceMRR =  ${renewalInvoice_cList.get(0).cALCULATEDMRR} )
#set( $ItemID = ${renewalInvoice_cList.get(0).Item_iD})
#set( $AutoRenew = ${renewalObject_cList.get(0).autoRenew})

#set( $interestingItems = [] )
#foreach( $item in $renewalInvoice_cList )
#if( $item.cALCULATEDMRR.ne("") )
#if( $item.autoRenew.equals("1") )
#set( $void = $interestingItems.add($item) )

#set( $nextRenewDate = $convert.parseDate($item.subscriptionEndDate,'yyyy-MM-dd') ) 
#set( $nextRenewSubDate = $convert.toCalendar($nextRenewDate) )

#if( $date.difference($calNow,$nextRenewSubDate).getDays() <= xx )
#set( $DisplayInvoiceMRR = $interestingItems.add($item.cALCULATEDMRR) )

$DisplayInvoiceMRR##
#elseif( $date.difference($calNow,$nextRenewSubDate).getDays() <= yy )
#set( $DisplayInvoiceMRR = $interestingItems.add($item.cALCULATEDMRR) )

$DisplayInvoiceMRR##
#end
#end
#end
#end
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Script- Addition of float field in MKTO custom Objects

Can you add Float (Float32) fields in Velocity? Yes, using MathTool.add ($math.add). Note they will be Doubles in Velocity.

 

But should you be using Float/Currency fields at all in Marketo? No, you should only use scaled Integers or Strings to store decimal/currency data. Floats do not have sufficient precision and you will get unexpected results.

View solution in original post

1 REPLY 1
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Script- Addition of float field in MKTO custom Objects

Can you add Float (Float32) fields in Velocity? Yes, using MathTool.add ($math.add). Note they will be Doubles in Velocity.

 

But should you be using Float/Currency fields at all in Marketo? No, you should only use scaled Integers or Strings to store decimal/currency data. Floats do not have sufficient precision and you will get unexpected results.