Help with Custom Object Velocity Script | Community
Skip to main content
New Participant
January 3, 2024
Question

Help with Custom Object Velocity Script

  • January 3, 2024
  • 1 reply
  • 3301 views

Hi there could use some help with troubleshooting some velocity script issues we are running into. We have a custom SFDC object that is related to the Person record via the account. We have checked off the fields used in the script as well as the company field. Here is the script we are trying to get to populate a date field:

 

## standard Velocity date/time includes #set ($company=$lead.Company) #set ($practice=$lead.Practice__c) #set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/New_York") ) #set( $defaultLocale = $date.getLocale() ) #set( $calNow = $date.getCalendar() ) #set( $ret = $calNow.setTimeZone($defaultTimeZone) ) #set( $calConst = $field.in($calNow) ) #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.SSS'Z'" ) #set( $ISO8601DateTimeWithMillisTZ = "yyyy-MM-dd'T'HH:mm:ss.SSSZ" ) #set( $SpendReach = $Practice__cList.get(0).SPO_Start_Date__c) ## Corrected date parsing using $dateTool #set( $dateIn = $dateTool.parseDate($SpendReach, $ISO8601DateOnly, $defaultLocale, $defaultTimeZone) ) ## Corrected date formatting pattern with single quotes #set( $dateOut = $date.format("d MMMM yyyy", $dateIn, $defaultLocale, $defaultTimeZone) )

 

 

However, in our emails it just remains blank even when sending to records that have a date. Let me know if I should add to another discussion thread.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

SanfordWhiteman
New Participant
January 3, 2024

$dateTool.parseDate does not exist. You want $convert.parseDate.

 

It’s not clear why you’re accessing the first item in the $Practice__cList every time. That’s usually a wrong move. You should only access the first item if you’ve specifically sorted or filtered the list so a certain item is known to be at the top.

 

Let me know if I should add to another discussion thread.

Definitely not!

NomadMa8Author
New Participant
January 3, 2024

Hi Sanford, In this example the custom object only has one record for each contact so we should only need the one record (or first record) that exists. Ill make that change in the script and see if it solves the issue.

SanfordWhiteman
New Participant
January 3, 2024
That may be the business expectation, but note Marketo will not stop you from creating multiple CO records. We frequently hear people say there's only one record per lead, only to find there are some leads with multiple records because the input isn't tightly controlled.