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.
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
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
Answers
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.
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Rishi
On your subpage you need someting like this:
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
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
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.
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/