Still struggling to find the most recent (last) time a particular order was done. However, I think the first getfield may be the problem, since this keeps returning nothing. And, a trace seemed to show that I had NULL. So, confused - which considering the breadth of GE help (online examples) - has me wondering if I have something set incorrectly. And I have cycled through other arrays. Ugh
This simplified version should list out all the orders; then I can add filter and date logic.
{local hold = getfield(ORDERS_ALL("delimited", "S"), "|", "")
local temp
local rslt = ""
for i = 1, i <= size(hold), i = i + 1 do
temp = getfield(hold[i], "^", "")
rslt = rslt + temp[2] + " - " temp[3] + " on " + temp[4] + HRET
endfor
rslt
}
We use this to find our last PAF order date and year. You welcome to modify it for your needs.
{!fn getPAFOrders()
{
local PAFvalue = ""
local PAFCount
local PAFRow
local PAForderslist
local PAFordersaray
local PAFordersaraysize
local LastYr =""
PAForderslist = ORDERS_ALL('DELIMITED','S')
PAFordersaray = getfield(PAForderslist,"|","")
PAFordersaraysize = size(PAFordersaray)
for PAFCount=1, PAFCount<=PAFordersaraysize, PAFCount=PAFCount+1 do
PAFRow = getfield(PAFordersaray[PAFCount],"^","")
If (str(PAFRow[3]) = "99420" or str(PAFRow[3]) = "CPT-99420" ) then PAFvalue = str(PAFRow[4])
Else ""
Endif
Endfor
If PAFvalue = "" Then PAFvalue = "None"
Else ""
Endif
Document.PAFDone = PAFvalue
Document.PAFYear = sub(str(PAFvalue),7,4)
LastYr = sub(str(._todaysdate),7,4) - 1
Document.LAST_YEAR = LastYr
return PAFvalue
}
}
Joseph,
have you tried using a two dimensional array instead? That's typically what I do. May sound crazy, but you might give it a try. I can send you an example if you would like.
There are an infinite number of ways to skin a cat, just use a sharp knife for starters.
{ fn Get_OrderDates()
{
local i=0
local strRet=""
local arrayOrder
local strOrder=""
local strOrderDate=""
strOrder=Orders_All("Delimited","S")
if strOrder<>"" then
arrayOrder=getfield(strOrder,"|","")
for i=1,i<=size(arrayOrder), i=i+1 do
arrayOrder[i]=getfield(arrayOrder[i],"^","")
strOrderDate=arrayOrder[i][4]
strRet=strRet+(if strRet<>"",HRET,"")+strOrderDate
endfor
endif
return strRet
}
}
Do you know how to show every instance that 99387 and 99397 was ordered in the last year? Its only showing most recent, but I figure it has to be a simple tweak. Below is the function and this is what I have in the data display:
getOrder("99387") + " " + getOrder("99397")
{fn getOrder(cptcode){
results = ""
orderArray = getfield(ORDERS_ALL("delimited"),"|","")
for c = 1, c 0 and durationdays(orderArray[c][4], str(._todaysdate)) < 731
then results = " " + orderArray[c][1] + ", " + orderArray[c][4] + ", " + orderArray[c][21]
endif endif
endfor
return results
}}
thanks!