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

Creating records from another record

(0) ShareShare
ReportReport
Posted on by 575

Hi guys

I'm starting to work my way through some of the books and videos on BC but I'm wondering about what I think should be a simple thing but can't seem to figure this out (brain drain no doubt).

I'm attempting to create a Purchase Quote record from a Sales Quote and I've got my Page Extension in place to extend Sales Quote, I have my Action in place and I have an OnAction in place with the following:

Page.Run(Page::"Purchase Quote");

Obviously all this is doing is opening the first Purchase Quote record when I click my Action button but I'd have thot there would be a similar command for creating a blank Purchase Quote...or am I missing something here?

What I'm ultimately attempting to do here is create the Purchase Quote and copy the Sales Lines from the Sales Quote.

This is a bit like the Copy Document functionality but I'm not sure how that works or if we can even see the AL underneath this.

Any advice appreciated.

Steven

I have the same question (0)
  • Suggested answer
    keoma Profile Picture
    32,729 on at

    you have to use the command with a record like page.run(<page>,<record>).

    create a new purchase header record, doc type=quote, fill the values from the sales header record, save it (insert), use it in the above call.

  • Steven O'Neill Profile Picture
    575 on at

    Hi Franz

    Thanx again for the response. I get what you mean here (you need a record in the command) but if we don't have a Purchase Quote yet then how can I add a record for it? The idea is I have the Sales Quote and from this I'm trying to create a blank Purchase Quote (it won't be blank eventually but baby steps atm whilst I'm still learning).

    So is creating a blank record done the same way (using Page.Run)?

    I have the other method we discussed basically working (using Sales and Purchase Orders) but I'm trying to ensure that the way I'm discussing here (creating the Purchase Quote from the Sales Quote) isn't a better way to do this.

    Hope that makes sense.

  • Verified answer
    keoma Profile Picture
    32,729 on at

    define a variable e.g. purchHeader of type record "purchase header".

    then write the code to set the properties.

    purchHeader."document type" := purchHeader."document type"::quote;

    //copy the relevant values from the sales quote

    purchHeader."document date" := salesHeader."document date";

    etc.

    then

    purchHeader.insert(true); // that sets the doc. no. and inserts the new record

    do the same with the lines.

    then call

    page.run(page::"purchase quote",purchHeader);

  • Steven O'Neill Profile Picture
    575 on at

    Excellent, thanx Franz. Makes total sense. I'm trying to bypass the actual creation piece by the looks of it. So I need to create the record first and then reference it.

    Thanx again

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,468

#2
YUN ZHU Profile Picture

YUN ZHU 923 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 607

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans