procedure proc1() var PurchPrice: Record Table1; begin PurchPrice.SetRange("Vendor No.", 'V001'); if PurchPrice.FindSet(true) then begin repeat if PurchPrice."Starting Date" = Today then proc2(); until PurchPrice.Next() = 0; end end;
procedure proc2() var purchPrice: Record Table1; begin purchPrice.Init(); purchPrice.Validate("Item No.", 'itemNo'); purchPrice."Vendor No." := 'V001'; purchPrice."Starting Date" := Today + 365; purchPrice.Insert() end;
You're using FindSet(true) which doesn’t lock the table (true parameter = allow write operations while iterating). This means that the record set is not truly static — it’s more like a dynamic pointer through a result set that can still be affected by changes made during the loop. So when you call proc2() and insert a new record that matches your current filter, it’s possible that the new record gets picked up by the loop — because Business Central’s underlying record iteration logic dynamically adjusts to table changes when using FindSet(true).
FindSet(true)
true
proc2()
I hope below is helpful.
Thanks, Ramesh
If this was helpful, please check the "Does this answer your question?" box and mark it as verified.
var PurchPrice: Record Table1; PurchPriceTemp: Record Table1 temporary; begin PurchPrice.SetRange("Vendor No.", 'V001'); if PurchPrice.FindSet() then repeat PurchPriceTemp.Insert(after setting every fields) until PurchPrice.Next() = 0; if PurchPriceTemp.FindSet() then begin repeat //logic on each record until end; 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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Rishabh Kanaskar 3,750
Sumit Singh 2,689
YUN ZHU 1,987 Super User 2025 Season 2