Update Header page from Lines page using interoperability

patrickverhoevenpatrickverhoeven Member Posts: 7
edited 2014-08-29 in NAV Tips & Tricks
Mark Brummel already wrote an example of this issue on his blog using an automation variable :
http://dynamicsuser.net/blogs/mark_brummel/archive/2009/12/16/tip-25-update-header-page-from-the-line-page.aspx

In the example below the SendWait function of System.Windows.Forms.SendKeys DoNet variabele is used.

Create a variable:
SystemWindowsFormsSendKeys DotNet 'System.Windows.Forms, Version=2.0.0.0,  Culture=neutral,PublicKeyToken=b77a5c561934e089'.System.Windows.Forms.SendKeys

Create a function in a codeunit and call this function from your page:
UpdatePageWithF5()
//Update a page
SystemWindowsFormsSendKeys.SendWait('{F5}');
SystemWindowsFormsSendKeys.SendWait('{F5}');

The reason for twice an 'F5' is that it does not update the main page first. First (and only) the fact boxes are updated.
As Mark also wrote: Be carefull with this hack since all flowfields are recalculated and there will be trafic to the SQL Box.

Comments

  • sharadsharad Member Posts: 112
    I've tried it in sales order page . I've made function in sales order sub form and put it to OnValidate trigger of Unit Price Incl all taxes of sales order subform page. but it's not working.
    It works when i minimize and maximize the form or when i push the f5 button twice.

    I want that it updates the header after moving to the next field.

    PLZ Help.
    Sharad Gupta
    Navision Technical Consultant & .Net Developer
  • DuikmeesterDuikmeester Member Posts: 304
    Shouldn't you use RunOnClient = Yes for the DotNet?
  • RallnusRallnus Member Posts: 79
    Sorry, but I've tried to use this logic with NAV 2013 and it didn't work.
    (including the "run on client" option in the automation variable property)
    What can be the reason for this?


    \:D/

    I've found the solution:
    I used "send" instead of "sendwait" and it worked fine.
    Rallnus (Yamaha FJ1200 - '89 / 25th anniversary was great!)
  • Prajeesh_NairPrajeesh_Nair Member Posts: 70
    Hi Rallnus :) ,

    I was trying to work in Nav 13 r2 with this code. I have tried both Send and SendWait methods. But got error for both the Methods.

    UpdatePageWithF5()
    //Update a page

    SystemWindowsFormsSendKeys.SendWait('{F5}');
    SystemWindowsFormsSendKeys.SendWait('{F5}');

    Error with SendWait
    Microsoft Dynamics NAV

    A call to System.Windows.Forms.SendKeys.SendWait failed with this message: Access is denied
    OK

    Error with Send
    Microsoft Dynamics NAV

    A call to System.Windows.Forms.SendKeys.Send failed with this message: SendKeys cannot run inside this application because the application is not handling Windows messages. Either change the application to handle messages, or use the SendKeys.SendWait method.
    OK
    I am using the application in Windows 7 -64 Bit operating system.
    Is there any problem with my code? :?:
    how to define RunOnClient = Yes for the DotNet?. Please guide me. Thanks [-o<
  • csimoneaux0527csimoneaux0527 Member Posts: 21
    RunOnClient is on the properties
  • sendohsendoh Member Posts: 207
    Hi All,

    how about using web client? is there a way to update the header from lines?I'm looking for a solution but can't find one, Please share if you already did this. Thanks in advance. :)

    Regards,
    Sendoh
    be smart before being a clever.
  • SuDSuD Member Posts: 102
    sendoh wrote: »
    Hi All,

    how about using web client? is there a way to update the header from lines?I'm looking for a solution but can't find one, Please share if you already did this. Thanks in advance. :)

    Regards,
    Place this OnValidate of Quantity in Line.
    IF SalesHeader.GET("Document Type","Document No.") THEN BEGIN
    SalesHeader."Total Quantity Of lines" := SalesHeader."Total Quantity Of lines" + Quantity;
    SalesHeader.MODIFY;
    COMMIT;
    END;

Sign In or Register to comment.