Get All the fields in a table through code in MSD axapta


Get All the fields in a table through code

The idea behind writing this job is to make clear the concepts of sqlDictionay and how to get the fields from a table. Also a little introduction to file generation class(TextBuffer).This job create a CSV file by name fieldlist in C: drive

 static void fieldsInTable(Args _args)  
 {  
 str fieldList = '';  
 SqlDictionary sqlDictionary;  
 TextBuffer buffer = new TextBuffer();  
 ;  
 while select * from sqlDictionary where sqlDictionary.tabId==tablenum(salestable)  
 {  
 fieldList += sqlDictionary.sqlName;  
 fieldlist += '\r';  
 }  
 if (fieldList)  
 fieldList = subStr(fieldList,1,strLen(fieldList)-1);  
 buffer.setText(fieldlist);  
 buffer.toFile("c:\\fieldslist.csv");  
 }