Calculate Value hook
Use this hook to calculate the value for the calculated field. The
value must be assigned to the variable with the name of the
Name
property. You must implement this hook for
Expression Type
Function
.
In this hook all fields of the main table are available. Those fields
can be found in the
Table Definitions session (ttadv4520m000).
Additionally, all selected fields from the Table Selections and the Calculated
Fields with other Expression Types than
Function
are available. You cannot use other
Calculated Fields with Expression Type
Function
, because the order in which the Calculate
Value hooks are executed is arbitrary.
Example for a field with Control Type Normal, no array field:
function extern void ext.price.calculate()
{
txprcdll0001.calculate.price(
tcibd001.item,
tcmcs023.catg,
utc.num(),
ext.price)
}
Example for a field with Control Type Normal, array field:
function extern void ext.turnover.calculate(i.elem.number)
{
long month
month = i.elem.number
txprcdll0001.calculate.turnover(tcibd001.item, month,
ext.turnover(i.elem.number))
}
Example for a field with Control Type URL Area:
function extern void ext.url.calculate()
{
ext.url = "https://www.infor.com"
}
Example for a field with Control Type Picture, graph:
function extern void ext.graph.calculate()
{
long ch, sr, cnt, ret
domain tccwoc office
ch = chart.new(CHART_TYPE_BAR)
chart.set.title(ch, "Orders by Sales Office")
chart.set.axis.type(ch, CHART_XAXIS, DB.STRING)
chart.set.axis.type(ch, CHART_YAXIS, DB.LONG)
sr = chart.add.series(ch, "Orders")
select tdsls400.cofc:office,count(tdsls400.orno):cnt
from tdsls400
group by tdsls400.cofc
order by tdsls400.cofc
selectdo
chart.add.data.point(sr, office, cnt)
endselect
ext.graph = creat.tmp.file$(bse.tmp.dir$())
ret = chart.write(ch, ext.graph, 400, 400)
}
Example for a field with Control Type Picture, the image stored on the file system in a custom location:
function extern void ext.item.image.calculate()
{
long ret
string image.file(256)
image.file = sprintf$(
"{BSE}/AppData/images/items/%s",trim$(tcibd001.item))
ext.item.image = creat.tmp.file$(bse.tmp.dir$())
ret = file.cp(image.file, ext.item.image)
}
Example for a field with Control Type Picture, the image that is linked to an existing Infor LN object. In this case a Business Partner:
function extern void ext.image.calculate()
{
long ret
ext.image = creat.tmp.file$(bse.tmp.dir$())
|* Field tccom100.imag included by Table Selection
ret = copy.image.to.file(get.compnr(), tccom100.imag,
"tccom100", ext.image)
}