loop through all fields in a table

Is there a way that I can loop through all fields in a table? I would like to be able to create a loop that will go straight through the sales table and give me the field names for each field in the SalesLine Table. Does anyone know if this is possible? Thanks in advance, Brian

Brian, use the TreeNode class (found in the System Documentation section of the AOT) - example: static void TEC_ListTableFields(Args _args) { #AOT TableName tableName = "SalesLine"; TreeNode treeNode; xInfo xInfo = new xInfo(); ; treeNode = xInfo.findNode(#TablesPath + "\\" + tableName); treeNode = treeNode.AOTfindChild("Fields"); treeNode = treeNode.AOTfirstChild(); while (treeNode) { info(treeNode.treeNodeName()); treeNode = treeNode.AOTnextSibling(); } } Cheers, H. Jaeger Tectura (UK) Ltd

Thanks this works perfectly… but now I have another question. Is there a way, as I am looping the treenodes, to get the value out of the table as well?

there are a lot of records in a table. (especially, SalesTable). Which record do you want values for? Or did you mean something else?

Brian, like Kashperuk I don’t understand what you’re looking for. If you want the data from the database do a select statement against the database (or possibly use a query). I do have feeling that this is not what you want! Maybe you’re looking to get the properties of the fields - in that case use the TreeNode.AOTgetProperties method - but let us know what you are looking to achieve so we can provide better help. Regards, H. Jaeger Tectura (UK) Ltd

Continuing the code from Henrik you may use this: SalesLine.(fieldName2Id(SalesLine.TableId,treeNode.treeNodeName()))

Thanks for the help… This works great!