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 :
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.

  • Suggested answer
    YUN ZHU Profile Picture
    104,157 Super User 2026 Season 2 on at
  • Suggested answer
    Nitin Verma Profile Picture
    21,812 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 624 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 440 Super User 2026 Season 2

#3
Teagen Boll Profile Picture

Teagen Boll 244 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans