Changing the active record of the parent form

jorgitojorgito Member Posts: 115
edited 2005-10-13 in Navision Attain
Hi all.

I have the following situation.

I have created a SubTable that is connected to the Sales Lines. When the user edits a specific sales line, he can press Shift-F9 and open the table SubTable in a form called SubForm that displays info relative to the specific Sales Line record.

The client has requested that the wants to simulate the following functionality with one button click from inside the subform : create a new sales line using the same Item No from the previous record and create a new line for the SubTable connected to the new Sales Line. All this without leaving the subform.

I have created this functionality, but I need to set the focus on the new Sales Line record BEFORE the user closes the SubForm, so that the SubForm shows the new SubTable record.

Any help?

Jorgito

Comments

  • randrewsrandrews Member Posts: 135
    Try use the Codunit Session with property SingleInstance=Yes (create this codunit).
    Create some variables in codunit which detect your sales line

    create variable of type Codunit Session in form with sales line and in SubForm
    define Session variables In SubForm
    Read this variables In form with sales line and use GET

    I did it. It works
  • randrewsrandrews Member Posts: 135
    Sorry. I forgot that BEFORE:
    jorgito wrote:
    I have created this functionality, but I need to set the focus on the new Sales Line record BEFORE the user closes the SubForm, so that the SubForm shows the new SubTable record.

    So I think to use OnTimer at form with sales line. OnTimer must check the variable at codunit Session
  • jorgitojorgito Member Posts: 115
    I don't think the OnTimer solution is the best.

    Imagine that the parent form shows record P1 which is linked to the S1 record in the SubTable. While the SubForm is open (modally), I want to move the record in the parent form to P2 and so show in the SubForm record S2 (which is linked to P2).

    How can I make a variable of the record in the parent form be accessible in the child form. I tried

    SalesLineChars.SetParentSalesLine(Rec);
    SalesLineChars.RUNMODAL;

    where SetParentSalesLine is

    SetParentSalesLine(VAR ParentSalesLine : Record "Sales Line")
    SalesLine.COPY(ParentSalesLine);

    and when the button is clicked I do

    SalesLine2.INIT;
    SalesLine2.VALIDATE("Document Type", "Document Type");
    SalesLine2.VALIDATE("Document No.", "Document No.");
    SalesLine2.VALIDATE("Line No.", LineNo);
    SalesLine2.VALIDATE(Type, SalesLineTemp.Type);
    SalesLine2.VALIDATE("No.", SalesLineTemp."No.");
    SalesLine2.INSERT;

    SalesLine := SalesLine2;

    I imagine that, since SalesLine (inside the subform) was copied from the Rec variable of the parent form, inserting a record would move the cursor to the new record. But it doesn't.

    Please, need desperate help!!

    Jorgito
  • jmjm Member Posts: 156
    Hallo,

    try:
    SalesLine2.INIT;
    SalesLine2.VALIDATE("Document Type", SalesLine."Document Type");
    SalesLine2.VALIDATE("Document No.", SalesLine."Document No.");
    SalesLine2.VALIDATE("Line No.", SalesLine.LineNo);
    SalesLine2.VALIDATE(Type, SalesLineTemp.Type);
    SalesLine2.VALIDATE("No.", SalesLineTemp."No.");
    SalesLine2.INSERT;

    br
    Josef Metz
    br
    Josef Metz
  • jorgitojorgito Member Posts: 115
    No. It still does not work.

    Let me point out that SalesLine is the record I have in the subform that I want to directly reference the records in the parent form.
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    I am not sure that I totaly understand you but,

    Have you tried to create the record before you run the form? So new the record is created before you call the form.run...
  • jorgitojorgito Member Posts: 115
    I have a SalesLineChar table that has the following fields: Document Type, Document No, Line No, ... (more fields). Each record in the SalesLineChar table corresponds to a Sales Line record. There is a form SalesLineChars that displays this record.

    I have a button in the Sales Orders that when it is pressed, it shows the SalesLineChar record for the chosen Sales Line record.

    What I want to do is, while showing (modally) the SalesLineChars form, to insert a new line in the Sales Line table and display the (new) record of the SalesLineChar table.

    Something like a) close the SalesLineChars form, b) insert a new Sales Line, c) Open the SalesLineChars form again (for the inserted record), WITHOUT CLOSING THE FORM. Just by clicking on a button in the SalesLineChars form.

    It is a very complicated situation and the client is quite paranoid, so I have to find a solution for this by Friday.

    Please help.
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Ok.

    A) So you open a form from an existing sales line showing existng char record
    B) You automaticaly create a new sales line and connected char record
    C) You want to focus on the new char record

    If this is right you can try changing the order

    B) Create the new salesline + char record
    A) Open the form, using the new char record
    C) is done automaticaly.

    If this is not possible you can try to use the GET statement in step C.
  • jorgitojorgito Member Posts: 115
    Mark,

    I cannot change the order, because the subform showing the (old) char record is already open and I want to create a new sales line + char WITHOUT CLOSING THE SUBFORM.
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Have you tried then doing a get() on the new char record after you have created it?

    Like

    NewChar.INSERT;
    GET(NewChar.Keyfields)

    If this does not work, just tell, then we need to be more creative. :D
  • jorgitojorgito Member Posts: 115
    While in the Subform, the form shows OldChar and the active Sales Line is OldSalesLine. What I want to do INSIDE THE SUBFORM is:

    SalesLine.INSERT;
    SalesLine.GET;
    SubForm.UPDATE;

    So now, the SubForm shows the NewChar (because the active record is NewSalesLine)

    Since the Subform is connected to the SalesLineSubform using Document Type, Document No and Line No, if I insert a new line in Char, it won't show, because the active Char line is OldChar and the active Sales Line line is OldSalesLine.

    I am pretty sure we must be creative. My deadline is tomorrow and I am running out of time.....

    Thanks in advance for all the help you have (will) given me!!
    Jorgito
Sign In or Register to comment.