
Hi everyone,
I am having one table i.e. CarTable. In this table I have CarId and I set its Mandatory property to Yes. Now, I am inserting one record through the following job:
static void InsertMethod(Args _args)
{
CarTable carTable;
;
//Initialize the table variable
carTable.initValue();
//Write some values to the table variable
carTable.CarId = "500";
carTable.CarBrand = "Audi";
carTable.Model = "A4";
carTable.ModelYear = 2009;
carTable.Mileage = 0;
if(carTable.validateWrite())
carTable.insert();
}
Now, validateWrite() will validate all the fields before insertion. It means, suppose if I am not using validateWrite() method then it wil allow me to insert the record without giving any value in CarId field?
It should not through any error, if I am inserting the record without CarId field but it is, why.
*This post is locked for comments
I have the same question (0)Hi,
It will still throw an error. It works more or less like below:
When you sync CarTable with database it makes the carId field mandatory in CarTable's definition.
When AX generated the insertion query and send to SQL, SQL Server will just complain about the missing value and not allow it to happen.