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 :
Small and medium business | Business Central, N...
Suggested Answer

I want Skip or Ignore Inserting record which one have a Error while inserting multiple records.

(0) ShareShare
ReportReport
Posted on by 78

Scenario: I have 2 table (custom Invoice and standard Purchase Header).
I am inserting multiple records using codeunit from "Custom Invoice" to " Purchase Header".
I want to put logic or validation that if any record facing error while inserting multiple records it should store value of error for that record and let it insert the next records.

I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    95,636 Super User 2025 Season 2 on at
  • Suggested answer
    Nitin Verma Profile Picture
    21,708 Moderator on at

    Hi,

    To achieve this you can do the following

    1. Create a functions in some other objects to Loop through your table to get the records

     Function()

    {

      table repeat

      codeunit.setparameter(table);

      if not codeunit.run() then

        logyourerror here in some other table.

     until table.next = 0;

    }

    2. Now as you can see we are calling Codeunit.run in if condition and before that we are setting up our table paramter

    codeunit 

    trigger OnRun ()

    begin

      recordingtransferfromhere;

    end;

    setparameter(table:record)

    begin

      table2 := table;

    end;

    local function recordingtransferfromhere()

    var

    destTable:record;

    begin

      destTable.transferfields(table2);

       destTable.insert();

    end;

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,577

#2
YUN ZHU Profile Picture

YUN ZHU 888 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 778 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans