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

Get record by fields other than the primary key

(0) ShareShare
ReportReport
Posted on by 92

On the "Reservation Entries" page there is a field called "Reserved for", which I need to also appear on the "Purchase Order Subform" page, for which I am developing an extension.

On the Reservation Entries page, this field uses the "CreateForText" procedure of the "Reservation Engine Mgt." Codeunit

pastedimage1634600586391v1.png

This procedure requires a parameter of type Record "Reservation Entry"

pastedimage1634600966886v2.png

In my extension of the page "Purchase Order Subform", I want to use this same procedure, but I need the parameter "Reservation Entry", which would be the reserved in each line of the table "Purchase Line".

I have noticed that the "Source ID" and "Source Ref. No." fields of "Reservation Entry" refer to the fields "Document No." and "Line No." from Purchase Line, so in my extension I want to create a variable of type Record "Reservation Entry", but that meets the criteria "Source ID" = "Document No." and "Source Ref. No." = "Line No.", how could I do this?

I had planned to use the "Get" method of "Record", but this only allows to use the primary key as a filter, and I would like to use the fields "Source ID" and "Source Ref. No."

I have the same question (0)
  • Suggested answer
    THE Italian Profile Picture
    on at

    ReservationEntry.SETRANGE("Source ID",Rec."Document No."):

    ReservationEntry.SETRANGE("Source Ref. No.",Rec."Line No."):

    if ReservationEntry.FINDFIRST then begin

    //do your stuff

    end:

    I have not the reservation entry under my finger tips but I think that you also have to populate Source Type with the appropriate document type (that is part of the key of purchase line table).

  • BchM Profile Picture
    92 on at

    Thanks for answering, just one more question, where should I put that code? Would it be in a trigger or should it be done in an extension of the Purchase Line table? Sorry, I'm totally new to Business Central, and in general as a programmer

    pastedimage1634660183623v1.png

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