web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Confusion in validateWrite() method

(0) ShareShare
ReportReport
Posted on by 120

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)
  • Suggested answer
    dolee Profile Picture
    11,279 on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans