web
You’re offline. This is a read only version of the page.
close
Skip to main content
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 103
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
    93,153 Super User 2025 Season 2 on at
    Get() a record using a temporary record
    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
    19,312 Super User 2025 Season 2 on at
    Get() a record using a temporary record
  • Rudylar Profile Picture
    103 on at
    Get() a record using a temporary record
    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 3,401

#2
Sumit Singh Profile Picture

Sumit Singh 2,692

#3
YUN ZHU Profile Picture

YUN ZHU 1,935 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans