Related information looks up the wrong record

ricky76ricky76 Member Posts: 204
edited 2013-01-23 in NAV Three Tier
Has anyone encountered this where the related information looks up the wrong line number from the sub page? I have a conditional statement which decides what will show depending on the status of the header but the information is picked up for the wrong line. I have everything set correctly in code so that the header calls the function on the sub page and then it is filtered on the line no.. However i can see by the filters on the page called that it hasn't looked up the correct line no. Any help would be appreciated. This is on 2009 R2.

Comments

  • David_CoxDavid_Cox Member Posts: 509
    Show the code and you will get an answer quicker, otherwise it will all be guess work!

    David
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • deV.chdeV.ch Member Posts: 543
    If i anderstand you correct, you have an action on the Header Page, this action calls a funktion on the sub page (lines page) right?
    This does not work, because RTC is not designed for it. If you call a function on the subpage it will always work with the first line, not the one you selected.
    You need to add the action on the subpage and call it from there.

    Although, there is a workaround, but it does not work perfectly: You can assign a keyboard shortcut to the action on the subpage und on the action of the header page you use send keys to simulate the keystrokes. The limitation is that you need to set the focus to the lines before you press the header action button, otherwise it does nothing.
  • ricky76ricky76 Member Posts: 204
    I have the related information option on the header page. My code is below

    CurrPage.RunShiftLines.FORM.ShiftDetails; //this is what i call from the related information

    //this is the code i have in the shift details function on the sub page
    IF Status IN [1..5] THEN BEGIN
    RunShift.RESET;
    RunShift.SETCURRENTKEY("No.",Line No.");
    RunShift.SETRANGE("No.","Document No.");
    RunShift.SETRANGE("Line No.","Line No.");
    FORM.RUN(0,RunShift);
    END ELSE BEGIN
    RunShiftJournal.SetShiftRec(Rec);
    RunShiftJournal.RUNMODAL;
    CLEAR(RunShiftJournal);
    END;
  • deV.chdeV.ch Member Posts: 543
    As i said this does not work, you can not call functions on the subpage, well you can..., but it will not trigger the right record, "Line No." will always be 10000 or wathever is your first line no.

    Refactor your solution to place the action on the subform itself, or use the Send Keys workaround.
  • ricky76ricky76 Member Posts: 204
    Thanks for your help. What do i need to do for the Send Keys workaround?
  • deV.chdeV.ch Member Posts: 543
    You can find information about using sendkeys easily in the forum by using the search.

    But here is how you do it:

    Assign a shortcut to the action in the subpage (eg: Alt+4)

    Then in the OnPush Trigger of the Header Action use this Code:
    IF ISCLEAR(WSHShell) THEN
      Create(WSHShell, TRUE, TRUE);
    WSHShell.SendKeys('%4');
    

    Where WSHSHell is an automation of type: 'Windows Script Host Object Model'.WshShell

    You can find a reference to SendKeys here: http://msdn.microsoft.com/de-de/library/system.windows.forms.sendkeys%28v=vs.80%29.aspx
Sign In or Register to comment.