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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to validate the insert/writing of a record without necessity of a trigger event?

(0) ShareShare
ReportReport
Posted on by

Consider I have just read a row from this csv file, each column is a field of a table,  I have been asked to verify that the value in that record of a certain field is plausible for writing/updating  in the associated table.

For example, field X can accept as values only the integers 10, 11, 12, 13......if on my csv file I read a record in which the field X has been set to 22, I should throw an error before I start any update/insert and prevent any processing of the whole row/record I read.

I usually always worked with validating the data that users inserted on forms the moment they inserted it, I never had a situation like this.

How can I call the validateWrite method without any triggerring event and verify that the value I just read is fit for writing?

Thank you very much.

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,990 Most Valuable Professional on at

    You can populate a table buffer with field values and call validateField() and/or validateWrite() methods. It doesn't save anything; that would require calling insert() or write().

  • Evaldas Profile Picture
    1,800 on at

    You can always call table buffer methods by directly calling them e.g. custTable.validateWrite or custTable.validateMethod(fieldId) for every field you need to validate.

    Or you can create your own validation methods and call from the class you are importing the CSV file.

    If you are using data entities, you should check data entity validation methods.

    Various options. Depends on what exactly you need.

  • WillWU Profile Picture
    22,363 on at

    Hi Fabio,

    You can verify this field when importing a CSV file.

    Refer to the following codes:

    CommaTextIo iO;
    FilenameOpen filename = @"C:\testFile.csv";
    Container record;
    boolean first = true;
    Table1 table1;
    
    iO = new CommaTextIo(filename,'R');
    while (iO.status() == IO_Status::Ok)
    {
      record = iO.read();
      if (record)
      {
        if (first) 
        {
          first = false;// skip the header
        }
        else
        {
          int num=conpeek(record, 1); 
          if(isInteger(num))
          {
          table1.yourfield)=num;
          }
          table1.otherfiled = conpeek(record, 2);
          //...
          table1.insert();
        }
      }
    }

  • Suggested answer
    Rahul Mohta Profile Picture
    21,032 on at

    also could explore option f using temp table and create copy over to temp and then use validation on temp rather on main table

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 669 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 449 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 384 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans