Running Subpage on Temporary Record in NAV 2016

Rishi1109Rishi1109 Member Posts: 43
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
Rishi
Thanks and Regards
Rishi

Answers

  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    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
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • Rishi1109Rishi1109 Member Posts: 43
    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
    Rishi
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    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.RESET;
    Rec.DELETEALL; //**make sure the 'old' data is gone
    SomeSourceRecord.SETRANGE(field, paramerer1)
    //
    REPEAT
      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
    IF Rec.FINDSET THEN;
    

    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
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • RockWithNAVRockWithNAV Member Posts: 1,139
    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.