Re: velocity script is rendering a random time, idky.

Dan-Pacifico
Level 2

velocity script is rendering a random time, idky.

Probably not the right Location for this but i'm trying to pull in a SFDC custom object formula field and it's spitting out a random time.

Script is pulling in everything right except the time. Anyone know why time is being weird?

#set ($sadate = 'not available')
#foreach($project in $project_task__cList)
#if( $project.Service_Type__c.toLowerCase().equals("randomness") || $project.Name.toLowerCase().equals("random"))
#set ( $sadate = $convert.parseDate($project.Service_Appointment_Start_Time__c, 'MM-dd-yy HH:mm') )

#end
#end
$sadate

 

should be Thu Jun 08 3:00 pm HST

 

is showing 

Thu Jun 08 14:00:00 CDT 2180

 

 

7 REPLIES 7
SanfordWhiteman
Level 10 - Community Moderator

Re: velocity script is rendering a random time, idky.

Impossible to answer as you haven’t shown the actual values you’re trying to parse. Property names don’t tell us anything about values.

 

You need to dump

$project_task__cList

and show the result.

Dan-Pacifico
Level 2

Re: velocity script is rendering a random time, idky.

@SanfordWhiteman can you elaborate? I thought the the foreach allows you to shorten the name later in the script ie - #foreach($task in $TASKRAY__Project_Task__cList) means that i can use $task instead of the long string later. 

 

The value i'm trying to pull is Service_Appointment_Start_Time__c which I working to get verification is a formula field in SFDC. I've pulled it in a few different ways and was using script i had seen you post before so I'm not sure i understand how to pull the correct value.

SanfordWhiteman
Level 10 - Community Moderator

Re: velocity script is rendering a random time, idky.

I mean you have to show the raw output here, on the Community, since there's no way to help you with parsing if you don't show the value you're trying to parse as a date with a particular format.
Dan-Pacifico
Level 2

Re: velocity script is rendering a random time, idky.

Heard.

 

$convert.parseDate($task.Service_Appointment_Start_Time__c, 'yyyy-MM-dd'))
#set ($sadate = 'not available')      
#foreach($task in $TASKRAY__Project_Task__cList)
    #if( $task.Service_Type__c.toLowerCase().equals("installation") || $task.Name.toLowerCase().equals("install"))
 #set ( $sadate = $convert.parseDate($task.Service_Appointment_Start_Time__c, 'MM-dd-yy HH:mm') )  
    #end  
#end
$sadate
SanfordWhiteman
Level 10 - Community Moderator

Re: velocity script is rendering a random time, idky.

That’s not output. It’s your code.

 

Again, you have not provided the raw values of the data you’re trying to parse. Like saying “Why doesn’t my string parse into a date using the format ‘yyyy-dd-MM ss:HH’?” without providing the value of the string.

 

Provide the output of the single line:

${TASKRAY__Project_Task__cList}

 

Dan-Pacifico
Level 2

Re: velocity script is rendering a random time, idky.

Is the output not what i put in the original post:

"

should be Thu Jun 08 3:00 pm HST

 

is showing 

Thu Jun 08 14:00:00 CDT 2180 

"

SanfordWhiteman
Level 10 - Community Moderator

Re: velocity script is rendering a random time, idky.

That doesn’t tell me what you’re parsing. Your string value might as well be “Lorem Ipsum”. Obviously that will not parse properly as a date using the provided format.

 

Please show the output of the single line I provided above, which will dump the list of objects and their properties.