Skip to main content

Posts

Showing posts with the label Ax Validation

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);

Use of Data Source Methods in MSD axapta

Use of Data Source Methods in axapta Adding a new record from a form will call the following sequence of data source methods: create() ► initValue() ► refresh() ► active() ► refresh() 1. The method create() is called when pressing ctrl+n to add a new record. 2. The data source initValue() is called by create(). You should initialize fields which must have a specific value in initValue(). The table method initValue() is called by super() in the data source initValue(). If the initialized values are not form specific, you should use the corresponding table method. 3. After initialization refresh() is called, and when entering a record active() is called. Refresh is called again by active(). When saving a record the following methods are called: validateWrite() ► write() ► refresh() 1. ValidateWrite() will call the table method validateWrite(). Again, always use the corresponding table methods if possible. 2. The data source method write() will call either insert() or update...

Example of code to Validate field in axapta using validate method of datasource

Example of code to Validate field in axapta using validate method of datasource public boolean validateField(fieldId _fieldIdToCheck) { boolean ret; ret = super(_fieldIdToCheck); if (ret) { switch (_fieldIdToCheck) { case fieldnum(MyTable, custName) : if (strlen(this.custName) <= 3) ret = checkFailed("Customer name must be longer than 3 characters."); } } return ret; }

check existence of table in axapta

This is sample code to  check existence of table in  axapta. This is just an example to check whether that table exist in AOT (Application object tree) or not. If table exist then it will return true otherwise it will show error the table is already exists. public boolean modified() { boolean ret; ret = super(); flag = false; value= Controlname.valueStr(); flag = TableName::exist(value); if (flag == true) { info("Already Exists"); } return ret; }