Need to retrieve the second product category in the list
Hi There! I would like to ask for some help regarding a script we are currently working on. This script works however there are some cases in which the order date is the same with other product category which result to error. The error occur for this example, I have data with Stickers and Postcards order at the same time but I just need to show the data for postcards which is in second list.
Sample data:
Itemlist 1 - Stickers - Order date: Oct 9, 2020
Itemlist 2 - Postcards - Order date: Oct 9, 2020
Itemlist 3 - Postcards - Order date: Sept 4, 2020
My question would be, how can I retrieve a data in Itemlist 2 using the lastindex value since I need to still get the recent purchase for a specific product.
#set($product = "Postcards")
#set($size = $jobItemList.size())
#set($lastIndex = $jobItemList.size() - 1)
#set($joID = ${jobItemList.get($lastIndex).jobOrderId})
#foreach( $item in $jobItemList )
#if ($item.productCategory == $product && $item.jobOrderId == $joID)
$item.jobOrderId
#break
#end
#end