Set Mandatory fields in Table through code in MSD axapta

Set Mandatory fields in Table through code in ax

 DictTable dictTable;  
 DictField dictField;  
 tableId tableId;  
 fieldId fieldId;  
 str result;  
 #DictField  
 ;  
 dicttable = new DictTable(tablenum(salestable));  
 for (fieldId = dictTable.fieldNext(0);fieldId;fieldId = dictTable.fieldNext(fieldId))  
 {  
 dictField = dictTable.fieldObject(fieldId);  
 if (!dictField.isSystem() && bitTest(dictField.flags(), #dbf_visible)  
 && bitTest(dictField.flags(), #dbf_mandatory))  
 {  
 result += dictField.name();  
 result +='\n';  
 }  
 }  
 info(result);