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

Get() a record using a temporary record

(4) ShareShare
ReportReport
Posted on by 115
Hi,
 
In order to get a static list of records from a FindSet(), I did the following because this record has 7 PK of different types and I couldn't reference in a list:
 
var
   PurchasePriceTemp: Record "Purchase Price" temporary;
begin
        PurchasePriceL.SetRange("Vendor No.", inVendorNo);
        if PurchasePriceL.FindSet() then begin
            repeat
                PurchasePriceTemp.Init();
                PurchasePriceTemp := PurchasePriceL;
                PurchasePriceTemp."Minimum Quantity" := 9999; // just as an identifier to make sure those temp records will not be saved on the real table
                PurchasePriceTemp.Insert();
            until PurchasePriceL.Next() = 0;
        end;
        if PurchasePriceTemp.FindSet() then begin
            repeat
                PurchasePriceL.Get(PurchasePriceTemp."Item No.", PurchasePriceTemp."Vendor No.", PurchasePriceTemp."Starting Date", PurchasePriceTemp."Currency Code", PurchasePriceTemp."Variant Code", PurchasePriceTemp."Unit of Measure Code", PurchasePriceTemp."Minimum Quantity");
                
                
And this is precisely when I try to Get() that exception is raised saying the record (temp) does not exist...
 
Any idea ?
I have the same question (0)
  • Verified answer
    YUN ZHU Profile Picture
    101,250 Super User 2026 Season 1 on at
    Hi, it seems that PurchasePriceL and PurchasePriceTemp only differ in the value of "Minimum Quantity". Why don't you just add your processing directly after insert?
    I personally don't think adding a second loop is necessary.
     
    As for your question, change PurchasePriceTemp := PurchasePriceL; to assign a value to the field separately.
    In addition, you can also add a message after if PurchasePriceTemp.FindSet() then begin
    repeat
    to check whether the value you are trying to get is empty.
     
    If you think the key is too long, you can also try to obtain it using SystemId.
    Dynamics 365 Business Central: How to get a record by its SystemId
     
    Hope this helps.
    Thanks.
    ZHU
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    22,444 Super User 2026 Season 1 on at
  • Rudylar Profile Picture
    115 on at
    I used the SystemId and it works great.
     
    Thank you 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,140 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,362 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,216

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans