The following job helps you find the related field of a table, in the e,g it tries to find the related field of (InventTrans, InventTransId) for the sales Line table
static void FindRelateField(Args _args)
{
SysDictTable dictTable = new SysDictTable(tableNum(SalesTable));
int i,j;
SysDictRelation dictRelation;
TableId externId = tableNum(PurchTable);
IndexId indexId;
//Searh the explicit relations
for(i=1; i <= dictTable.relationCnt(); i++)
{
dictRelation = new SysDictRelation(dictTable.id());
dictRelation.loadNameRelation(dictTable.relation(i));
// If it is a 'relation' then you use externTable(), but for extended data types you use table() (see next blook)
if(SysDictRelation::externId(dictRelation) == externId)
{
for(j=1; j <= dictRelation.lines(); j++)
{
info(strFmt("%1", dictRelation.lineExternTableValue(j)));
info(fieldId2name(dictRelation.externTable(), dictRelation.lineExternTableValue(j)));
}
}
}
info(strFmt("%1", dictRelation.loadFieldRelation(fieldNum(SalesLine,InventTransId))));
}
Không có nhận xét nào:
Đăng nhận xét