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

Announcements

No record found.

News and Announcements icon
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.

  • Suggested answer
    Martin Dráb Profile Picture
    240,922 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,046 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 555 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 484 Super User 2026 Season 2

#3
CU10121822-0 Profile Picture

CU10121822-0 378

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans