I created a dynamic list box that will display incomplete Test Orders, and the list box is blank unless I also have a data display in the form. I'm confused. The data display I added contains {ORDERS_AFTER("delimited")}. That's it. No translation or anything extra. And, the list box is populated by the below function, but doesn't work without the data display.
We upgraded CPS last month (to 12.2.3.4289) and while developing forms have noticed some quirkiness that I can't pinpoint, but this is weird. Are you able to replicate this in your system or is there anything about the below function that could explain this? I haven't called GE yet, wanted a second opinion first. Thanks in advance!
{fn TestOrders(orderlist)
{
ordArr = getfield(orderlist,"|","")
Local NewordList = ""
Local Counter
if size(ordArr)==0 then NewordList = "" else
ordArrL = size(ordArr)
for Counter=1, Counter<=ordArrL, Counter=Counter+1
Do oneOrder = getfield(ordArr[Counter],"^","")
if oneOrder[2]=="T" then
IBuffer = replacestr(oneOrder[1], ",",";")
NewordList = NewordList + IBuffer + " (order date: " + oneOrder[4] + ")" + ", "
else "" endif
endfor
endif
/* Remove trailing comma */
if (Counter > 1) then
NewordList = remove(NewordList, size(NewordList))
endif
/* Return comma separated list */
return Newordlist
}}{TestOrders(ORDERS_AFTER("Delimited"))}
It is imperative to understand how variables work inside functions. In the code, the following variables are declared in a GLOBAL state, meaning they are available outside of the function.
ordArr
ordArrL
oneOrder
IBuffer
To ensure that these variables are not being affected by similar syntax issues elsewhere, you might want to make them local to the function. (i.e. local ordArr)
You will also want to use a 'bam' in the declaration statement of the function to ensure that it loads into memory before the function call, otherwise, there is no trigger to force it to refresh after the first pass (unless a new order is added or an old one is completed - then it would refresh).
{! fn TestOrders(orderlist)
{
local etc.
}
}
If you clean those items up, I think it should work for you.
Hope this helps.
Thank you, that worked. I'll be more aware of that.