Running Subpage on Temporary Record in NAV 2016

Rishi1109Rishi1109 Posts: 40Member
Hello Friends ,

Is it any how possible to run subpage on a Temporary Record set which will be populated through code written in OnOpenPage of main Page ?

Any help would be highly appreciated.

Thanks and Regards
Thanks and Regards


  • Slawek_GuzekSlawek_Guzek Posts: 1,488Member
    edited 2018-07-21
    You have posted the question and the answer - populate the temp record in the subpage through the code.

    Build a function on your subpage which will populate the data, and call it on OnAfterGetCurrentRecord on the main page, passing the relevant parameters (or a record) from the main page - so the data in the subform can be related to the record actually displayed on the main page.
    Slawek Guzek
    Poszukuje programistow znajacych Microsoft Dynamics NAV
  • Rishi1109Rishi1109 Posts: 40Member
    Thanks Slawek for your time but I just wanted to understand that if I have put Rec1 as sourcetable property of subpage then where and how to assign TempRec1 to rec1
    Thanks and Regards
  • Slawek_GuzekSlawek_Guzek Posts: 1,488Member
    You need to have a code on the subpage populating your Rec record on the subpage

    On your subpage you need someting like this:
    SetSubpageData (some paramerer1...)
    Rec.DELETEALL; //**make sure the 'old' data is gone
    SomeSourceRecord.SETRANGE(field, paramerer1)
      Rec.Field1 = SomeSourceRecord.Field1
      //and so on
      Rec.INSERT; //**insert new data into Rec on the subpage
    UNTIL you have all the data in Rec

    The Rec on the supbage is your source record on that subpage, the SourceTableTemporary property on the subpage must be set to Yes.

    It does not matter how you set values on the Rec record; using a set of assignments as on the mockup code above, use Rec := SomeOtherRecordOftheTypeSameAsRec, or if you use SomeDifferentRecotr.TRANSFERFIELDS(Rec); Once you have set all required fields you simply do Rec.INSERT to insert new record into your subpage.

    If you already have some data prepared in some temp record you need to pass your temprecord to the Page. then pass it further down to the subpage, and copy the data from the temprecord to Rec on the subpage.

    You can pass your temprecord to the Page in two ways: If your page is based on the same record type you ou can run your page by calling RUN(PageID, temprecord), and then you need to pass by reference you Rec record from the header to the function on the subpage.

    If your header shows data from different record than temprecord then you need to add another function on the header, define page as variable, and call this new function on page variable to setup data in subpage before calling PageVar.RUN

    Slawek Guzek
    Poszukuje programistow znajacych Microsoft Dynamics NAV
  • RockWithNAVRockWithNAV Posts: 691Member
    OnOpenPage Trigger -

    I normally never suggest to call anything or large set of code from this trigger until and unless its deadly needed. It will slow down your Page.
Sign In or Register to comment.