{!
fn OrdersStat() {
local temp = getfield(ORDERS_NEW("Delimited"),"|","")
local hold
local rslt =""
for i=1, i<=size(temp),i=i+1 do
hold = getfield(temp[i],"^","")
if hold[12] =="S" then
if rslt <>"" then
rslt = rslt + hret
endif
rslt = + rslt + hold[1]
endif
endfor
return cfmt(rslt, ",1")
}}
This function populates my data display fine.
The trouble comes with the text. I doesn't populate unless I place the document on hold and reenter it.
Any thoughts?
I recall vaguely this issue in the remote past. Just a thought, put rslt into a document field, use the field for your data display, translate the document field not the data display. Although you could use a global variable, these disappear on putting document on hold.
Not quite following, rslt into a document field? Like so, {!DOCUMENT.RSLT = OrdersStat()}? This seems to evaluate the function the same.
Create a data display field and have it set to type= Mel Expression then use {OrdersStat()} this should call the function each time a field is updated.
You can hide this field so it doesn't show up on your form.
This is what I'm doing and it does update the display continuously but not the text translation.
Here was my solution:
Data display hooked to function:
{!fn OrdersStat() {
local temp = getfield(ORDERS_NEW("delimited"),"|","")
local hold
local rslt =""
for i=1, i<=size(temp),i=i+1 do
hold = getfield(temp[i],"^","")
if hold[12] =="S" then
if rslt <>"" then
rslt = rslt + hret
endif
rslt = "THIS ORDER IS STAT: " + hold[1] + hret + rslt
endif
endfor
return rslt
}}
in the data display text translation:
{if DOCUMENT.SHOW_IN_NOTE = "yes" then FMT(OrdersStat(), "1") else "" endif}
Created rad btn with "yes,no"
In white space trick the rad btn:
{if ORDER_LIST_CHANGES() <> "" then DOCUMENT.SHOW_IN_NOTE = "yes" else DOCUMENT.SHOW_IN_NOTE = "no" endif}
{if ORDER_LIST_CHANGES() <> "" then DOCUMENT.SHOW_IN_NOTE = "no" else DOCUMENT.SHOW_IN_NOTE = "yes" endif}
This allows the text translation to reevaluate to grab addition Stat orders.