if you want to call method dynamically, by just knowing its name and Table Name, you can code it as demonstrated below.
Note that I am going to use a job, for demonstration purpose. you may keep this method as any static method and may call it any number of times, if needs.
Such method can be useful in integration scenarios, where you may need to call a specific method by knowing its name only.
static void CallTableMethodByCode_SMC(Args _args)
{
Common buffer;
anytype result;
RecId recId = 22565422954; //recordId for Buffer
str methodName;//variable for method name
str tableName;//variable for TableName
SysDictTable dictTable;//SyDictTable object
;
//TableName , MethodName WHICH needed to be called.
//For my vase i am calling name() method
methodName = tableMethodStr(VendTable,name);
//Table for whcih method is called
tableName = tableStr(VendTable);
//initialize SysDictTable object
dictTable = new SysDictTable(tableName2Id(tableName));
if (dictTable != null)
{
buffer = dictTable.makeRecord();
select firstOnly buffer
where buffer.RecId == recId;
if (buffer.RecId != 0)
{
result = dictTable.callObject(methodName, buffer);//dynamic call to method
info(result);
}
}
}
//Happy Daxing!

Like
Report
*This post is locked for comments