New record and CardPageID - how to pass parameters?

alex9alex9 Member Posts: 97
edited 2014-05-23 in NAV Three Tier
Here is a situation.
There are two pages: MyList page and MyCard page, the same source table. I need to copy some field value from selected record to the new record when I am inserting a new record.
I can do that on the MyList page with the code:
OnNewRecord(BelowxRec : Boolean)
rec.MyField := xRec.MyField;
However, this doesn't work when I specify CardPageID on MyList page. In that case, MyCard page is opening when I click New (or ctrl+N) on MyList page. The problem is, MyPage card doesn't know anything about xRec, it's just empty.

Is there any way to pass some values from List page to Card page when CardPageID is used and new record is inserted?

Comments

  • suvidhab_ssuvidhab_s Member Posts: 16
    Hi,

    I created a customer list page and a card page. Linked them together (CardPageID).

    Wrote the below code on OnNewRecord trigger of the Card page.
    Address:= xRec.Address;

    When I clicked on New on the list page, the address is getting picked from the last record in customer table into my new record.

    If you want to copy the xrec fields from a specific record, it might not be possible directly.
  • alex9alex9 Member Posts: 97
    Yes, it is picked from the last record, which does not make a lot of sense. It needs to be copied from the record which is selected at the moment when I click New. It does so when I am creating new record from a standalone list. But CardPageID is used, it doesn't work.

    Does somebody know any workaround? The only idea I have is to create my own list instead of standard one (page 9308 "Purchase Invoices" in my case), create custom action "New" with code which passes parameter to Purchase Invoice card and disable standard action "New" somehow. Any other ideas? And how to disable standard action "New", by the way?
  • alex9alex9 Member Posts: 97
    alex9 wrote:
    Does somebody know any workaround? The only idea I have is to create my own list instead of standard one (page 9308 "Purchase Invoices" in my case), create custom action "New" with code which passes parameter to Purchase Invoice card and disable standard action "New" somehow. Any other ideas? And how to disable standard action "New", by the way?
    Partially answering my own question, that new list should have InsertAllowed=No, so standard "New" won't appear. Still not sure this is the best approach.
Sign In or Register to comment.