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
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.
Navision Technical Consultant & .Net Developer
(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.
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<
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,
be smart before being a clever.
IF SalesHeader.GET("Document Type","Document No.") THEN BEGIN
SalesHeader."Total Quantity Of lines" := SalesHeader."Total Quantity Of lines" + Quantity;
SalesHeader.MODIFY;
COMMIT;
END;