Options

Set and get current record

RainerRainer Member Posts: 103
From a form I have to "save" the current record as follows:

1. I am on form A with record from table A:
· I click to open form-X with some code in.

...or

2. I am on form B with recordfrom table B:
· I click to open form-X with some code in.

...or

3. I am on form C with recordfrom table C:
· I click to open form-X with some code in.

In these 3 cases I need to know what is the current record... is it from A, B or C?

How?
Kind Regards

E-mail: info@rainerbay.dk
Skype: rainerbaydk

Comments

  • Options
    bbrownbbrown Member Posts: 3,268
    Is form X called from a button on forms A, B, and C?

    If yes:

    1. On Form X create a global for tables A, B and C

    2. On Form X create a global option var. Options = (A,B,C)

    3. On Form X create 3 functions (SetA, SetB, SetC). These fuctions should receive the appropriate record as a parameter and asign to the global record defined in step 1. They should also assign the appropriate value to the option var.

    4. From the button on forms A, B, and C. Declare form X as a global. Call the appropriate function and run form X. (Don't forget to clear the form variable)

    Form X can check the value of the option field to determine how it was called. And will have a copy of the record used to call it.

    Hope this helps..
    There are no bugs - only undocumented features.
  • Options
    RainerRainer Member Posts: 103
    bbrown, thanks.

    On my Bottom F9 code, can you define how... Error "its not allowed to run the form in this mode"... or am I just stupid... (maybe) :roll:
    Kind Regards

    E-mail: info@rainerbay.dk
    Skype: rainerbaydk
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    What is the exact error you are getting? Is it saying not to run modal?

    Can you please explain more, also functional, what you are trying to achieve? It sounds interesting but I do not completely understand the big picture. :?
  • Options
    RainerRainer Member Posts: 103
    From one form (bottom) I need to call another form, and in this new opened form, I need to know from exactly which record I "came".

    I need to open same form from many other forms, same code and all.

    Example:
    From Customerform : Open new form and "look" at current customer
    From Vendorform : Open new form and "look" at current vendor
    From Itemform : Open new form and "look" at current Item

    In the old N3 was these "funtions" dbSETCURREC(customer) and dbGETCURREC(customer).

    The same is while you call a codunit forexample for booking invoice, and "send" the SalesHeader to the codeunit.

    Rainer
    Kind Regards

    E-mail: info@rainerbay.dk
    Skype: rainerbaydk
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Can't you just do
    Form.runmodal("Item card", rec);
    

    PS. Welcome to Navision for windows. :D
Sign In or Register to comment.