So my issue here is when brining up the form and clicking my buttons the first time sometimes doesn't work and it is very random when it will and will not work there after, but for sure 70% of the time the first initial click won't trigger the function behind it. Here is my function for the 3 buttons:
/**button to add order**/
{fn add_order(clist,sorder,sprob,comment,sdate)
{
local ordera = ""
local ordersz
local counta
local oneorder = ""
ordera = getfield(ORDER_CUST_LIST(clist),"|","")
ordersz = size(ordera)
for counta = 1, counta <= ordersz, counta = counta + 1 do
oneorder = getfield(ordera[counta],"^","")
if match(sorder,oneorder[2]) > 0 then
MEL_ADD_ORDER(oneorder[1],oneorder[4],oneorder[2],"",get_dx(sprob,3),get_dx(sprob,2),comment,"","","",sdate)
endif
endfor
return blank
}
}
/**button to add future order**/
{fn add_future_order(clist,sorder,sprob,comment,sdate)
{
local orderaa = ""
local ordersza
local countaa
local oneordera = ""
orderaa = getfield(ORDER_CUST_LIST(clist),"|","")
ordersza = size(orderaa)
for countaa = 1, countaa <= ordersza, countaa = countaa + 1 do
oneordera = getfield(orderaa[countaa],"^","")
if match(sorder,oneordera[2]) > 0 then
MEL_ADD_ORDER(oneordera[1],oneordera[4],oneordera[2],"",get_dx(sprob,3),get_dx(sprob,2),comment,"","","",sdate)
endif
endfor
return blank
}
}
/*every week for a month*/
{fn add_every_week_for_1_month(clist,sorder,sprob,comment,sdate)
{
local orderab = ""
local orderszb
local countab
local oneorderb = ""
orderab = getfield(ORDER_CUST_LIST(clist),"|","")
orderszb = size(orderab)
for countab = 1, countab <= orderszb, countab = countab + 1 do
oneorderb = getfield(orderab[countab],"^","")
if match(sorder,oneorderb[2]) > 0 then
MEL_ADD_ORDER(oneorderb[1],oneorderb[4],oneorderb[2],"",get_dx(sprob,3),get_dx(sprob,2),comment,"","","",sdate)
MEL_ADD_ORDER(oneorderb[1],oneorderb[4],oneorderb[2],"",get_dx(sprob,3),get_dx(sprob,2),comment,"","","",ADDDATES(str(sdate), "0", "0", "7"))
MEL_ADD_ORDER(oneorderb[1],oneorderb[4],oneorderb[2],"",get_dx(sprob,3),get_dx(sprob,2),comment,"","","",ADDDATES(str(sdate), "0", "0", "14"))
MEL_ADD_ORDER(oneorderb[1],oneorderb[4],oneorderb[2],"",get_dx(sprob,3),get_dx(sprob,2),comment,"","","",ADDDATES(str(sdate), "0", "0", "21"))
endif
endfor
return blank
}
}
Any ideas are very much welcome, I've been tweaking this for a week now and cant get a resolution.
I should also add that each button clears the fields that go into mel_add_order (clist,sorder,sprob,comment,sdate) otherwise the second click won't work either.
Daniel, please email me the dlg for the form so I can see what you are doing. I will show you how to fix one of the buttons then let you get some practice by fixing the others. 😉
Sent it, let me know if you need anything else!