Announcements
No record found.
container myCon = ['table1','table2','table3','table4','table5','table6' ]; ; for(i = 1; i<=6, i++) { while select count (RecID) from conPeek(myCon, i) { do smth } }
*This post is locked for comments
Hi,
the following will do what you need ...
container tableIDs = [tableNum(InventTable), tableNum(CustTable)]; int i; void doSomething(TableId _tableId) { DictTable dictTable; Common common; DictTable = new DictTable(_tableId); Common = dictTable.makeRecord(); select count(RecId) from common; info(strFmt("%1:%2", DictTable.name(), Common.RecId)); } for (i = 1; i <= conLen(tableIDs); i++) { doSomething(conPeek(tableIDs, i)); }
Hope this helps!
Kind regards,
Annette
static void Job4(Args _args)
{
SysDictTable dt = SysDictTable::newName('InventTable');
Common cm = dt.makeRecord();
while select cm
info(strFmt('%1', cm.getFieldValue('ItemId')));
}
Hallo Ivan,
thanks for your reply.
However I am looking for something that will loop through a few tables - I guess I would want to set a number in the function newName rather than the table name like
newName('InventTable').
I also noticed that it is possible to get only this function :
SysDictTable::newTableId
and not
SysDictTable::newName('InventTable');
this is just a string - you can pass in a variable or anything else in there.
Or, rather, answering the second part - you seem to be on an earlier version of AX, where the newName() method does not exist yet. newTableId() is just as good. Only instead of the table name, you need to pass in the ID of the table.
You can get it based on the name through tablename2id() function, if necessary
Also take a look at the example Annette provided, where she uses new DictTable() instead - the end result is the same, just a preference, I guess, of not using the new constructor directly
Oh, didn't mean to say anything by using new DictTable() ... old habits, I guess, though that's not an excuse I myself would accept :-S
So: Of course it's cleaner code to use SysDictTable!
(My point was more about how to get from the container full of tableIDs to counting the records in each of the tables; that's what I thought the original question was about)
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
Congratulations to our 2026 Super Stars!
We are thrilled to have these Champions in our Community!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
CP04-islander 39
Michel ROY 14
imran ul haq 8