Which IIQ version are you inquiring about?
IIQ Version 8.4p1
Please share any images or screenshots, if relevant.
[Please insert images here, otherwise delete this section]
Please share any other relevant files that may be required (for example, logs).
Certification Email Template.txt (2.7 KB)
Share all details about your problem, including any error messages you may have received.
I am trying to convert the lastLogonTimeSTamp to the below mentioned Date Format, but it is only printing $lastLogon and not the value.
#set( $lastLoginRaw = $lnk.getAttribute("lastLogonTimeStamp") )
#if($lastLoginRaw)
#set( $longValue = $spTools.toLong($lastLoginRaw) )
#set( $windowsEpochAdjustment = 11644473600000 )
#set( $lastLoginMillis = ($longValue / 10000) - $windowsEpochAdjustment )
#set( $dateObj = $dateTool.get($lastLoginMillis) )
#set( $lastLogon = $dateTool.format("dd-MMM-yyyy hh:mm a", $dateObj) )
#end
<tr>
<td>$lnk.getAttribute("sAMAccountName")</td>
<td>$hasEmail</td>
<td>$lastLogon</td>
</tr>
#end
Hi and Hello,
You have this line:
<td>$lastLogon</td>
But if $lastLoginRaw is null (or blank), then $lastLogon is never set, because it’s inside this block:
#if($lastLoginRaw)
#set( $longValue = $spTools.toLong($lastLoginRaw) )
#set( $windowsEpochAdjustment = 11644473600000 )
#set( $lastLoginMillis = ($longValue / 10000) - $windowsEpochAdjustment )
#set( $dateObj = $dateTool.get($lastLoginMillis) )
#set( $lastLogon = $dateTool.format("dd-MMM-yyyy hh:mm a", $dateObj) )
#end
So in cases where lastLogonTimeStamp is missing, $lastLogon is not defined at all.
And when Velocity tries to print an undefined variable, it just prints the variable name ($lastLogon) literally.
What you can do?
Initialize $lastLogon
with some default value before your #if($lastLoginRaw)
block.
#set( $lastLogon = "N/A" )
#if($lastLoginRaw)
#set( $longValue = $spTools.toLong($lastLoginRaw) )
#set( $windowsEpochAdjustment = 11644473600000 )
#set( $lastLoginMillis = ($longValue / 10000) - $windowsEpochAdjustment )
#set( $dateObj = $dateTool.get($lastLoginMillis) )
#set( $lastLogon = $dateTool.format("dd-MMM-yyyy hh:mm a", $dateObj) )
#end
That way, if the lastLogonTimeStamp is missing, $lastLogon will still have a value (“N/A” or whatever you choose), and the email will look cleaner.
Regards,
Adam
I did try initializing the value to "N/A’ before, but that did not work too.
I tried it again and added like this below. It still prints $lastLogon. And I am trying this for 2 accounts, which have a value in lastLogonTimeStamp.
#set( $lastLogon = "N/A" )
#set( $lastLoginRaw = $lnk.getAttribute("lastLogonTimeStamp") )
#if($lastLoginRaw)
#set( $longValue = $spTools.toLong($lastLoginRaw) )
#set( $windowsEpochAdjustment = 11644473600000 )
#set( $lastLoginMillis = ($longValue / 10000) - $windowsEpochAdjustment )
#set( $dateObj = $dateTool.get($lastLoginMillis) )
#set( $lastLogon = $dateTool.format("dd-MMM-yyyy hh:mm a", $dateObj) )
#end
<tr>
<td>$lnk.getAttribute("sAMAccountName")</td>
<td>$hasEmail</td>
<td>$lastLogon</td>
</tr>
Just FYI, I tried printing the values of all the variables and below was the output.
LastLoginRaw: 133890612121250141
LongValue: $longValue
LastLoginMillis: $lastLoginMillis
DateObj: $dateObj
LastLogon: $lastLogon