Update Main form from Subform

sendoh
Member Posts: 207
hi all,
I want to know is it possible to update the main form from subform please tell me how..
thnx...
I want to know is it possible to update the main form from subform please tell me how..
thnx...
Sendoh
be smart before being a clever.
be smart before being a clever.
0
Comments
-
If you will search this forum, you will find out that there are ways how to do that... simulating keys (through SendKey), timer etc...0
-
Hi..
By FORM.UPDATE you can update the Header form.
For Subform Give the name to the Subform.
ON OnValidate() trigger
CurrForm.SAVERECORD;
CurrForm.Name of Subform.FORM.Update();
And in the Subform create Function called Update()
and write code.
CurrForm.UPDATE(FALSE);
By written this you can update Subform.JAYESH PATEL-1 -
JAYESH wrote:Hi..
By FORM.UPDATE you can update the Header form.
For Subform Give the name to the Subform.
ON OnValidate() trigger
CurrForm.SAVERECORD;
CurrForm.Name of Subform.FORM.Update();
And in the Subform create Function called Update()
and write code.
CurrForm.UPDATE(FALSE);
By written this you can update Subform.
Your scenario will update Subform from Form, but not Form from Subform.Nav 4.0 sp30 -
I actually update the main form from the subform, but I have to click the main form before it update. please give me some hints.... :-kSendoh
be smart before being a clever.0 -
subform should know nothing about main form and it should be up to main form to manage itself. Try to rwrite your code in such a way that you do not need to update main form from subform. Most likely you will need to move some code from subform to main form0
-
thanks for the advice eugene,but this is the quick view..
in my subform there are the lines of amount
25.00
300.00
500.00
and I have to show the total of line amount...
825.00
this is the quick view for the user to see the total amount of their P.O.Sendoh
be smart before being a clever.0 -
sendoh!
Read kine replay!
Set up timer on main form and update it from time to time. Or you may show total in subform.
Search ruleazzz[/b]
Nav 4.0 sp30 -
my solution to this is not showing the total amount until the entering of the lines is finished. Once it is finished (a conformation on the header form that changes the state of the whole document from open to confirmed and blocks further data entering in the lines) the total amount is calculated once.
You do not really want to degrade system efficiency by constantly recalculating total amount.
I mean you can do it your way but is it a good design decision ?
Navision uses separate Statistics tab-page on the forms to avoid constant re-calculation.
I see two problems with calculate-on-change design:
1) your subform maybe used from several different main forms so you would need to inform every type of main form
2) the underlying lines the subform shows can be simultaniously updated from different places (e.g. by other client)0 -
-
sendoh wrote:thanks for the advice eugene,but this is the quick view..
in my subform there are the lines of amount
25.00
300.00
500.00
and I have to show the total of line amount...
825.00
this is the quick view for the user to see the total amount of their P.O.0 -
Thanks for the reply guys...I Follow what Vilnius said
my solution to this is not showing the total amount until the entering of the lines is finished.Sendoh
be smart before being a clever.0 -
when you need to update an Main Form from an Subform you can't do this with standard navision functions like Mainform.update. Ok you can use an Timer or an single insta. Codeunit, but this is an :-( solution. But why not using XMLDom -> M$ maked it possible ;-)
OBJECT Form 50000 Parent { OBJECT-PROPERTIES { Date=07-08-30; Time=15:14:11; Modified=Yes; Version List=; } PROPERTIES { Width=8000; Height=4840; OnOpenForm=BEGIN CREATE(XmlDoc); CurrForm.SubForm.FORM.SetXmlDoc(XmlDoc); END; OnCloseForm=BEGIN CLEAR(XmlDoc); END; } CONTROLS { { 1000000000;TextBox;330 ;220 ;4290 ;440 ;Editable=No; SourceExpr=TextVar } { 1000000001;SubForm;220 ;880 ;7480 ;2310 ;Name=SubForm; SubFormID=Form50001 } } CODE { VAR TextVar@1000000000 : Text[50]; XmlDoc@1000000001 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{88D969C0-F192-11D4-A65F-0040963251E5}:'Microsoft XML, v4.0'.DOMDocument40" WITHEVENTS; EVENT XmlDoc@1000000001::ondataavailable@198(); BEGIN END; EVENT XmlDoc@1000000001::onreadystatechange@-609(); BEGIN IF (XmlDoc.readyState = 4) THEN BEGIN TextVar := CurrForm.SubForm.FORM.GetText(); CurrForm.UPDATE(FALSE); END; END; BEGIN END. } } OBJECT Form 50001 Child { OBJECT-PROPERTIES { Date=07-08-30; Time=15:19:54; Modified=Yes; Version List=; } PROPERTIES { Width=8030; Height=2420; } CONTROLS { { 1000000000;TextBox;220 ;220 ;4180 ;440 ;SourceExpr=TextVar1; OnAfterValidate=BEGIN SendMessage(); END; } { 1000000001;TextBox;220 ;770 ;4180 ;440 ;SourceExpr=TextVar2 } } CODE { VAR TextVar1@1000000000 : Text[50]; TextVar2@1000000002 : Text[50]; XmlDoc@1000000001 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{88D969C0-F192-11D4-A65F-0040963251E5}:'Microsoft XML, v4.0'.DOMDocument40"; PROCEDURE SetXmlDoc@1000000000(pXmlDoc@1000000000 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{88D969C0-F192-11D4-A65F-0040963251E5}:'Microsoft XML, v4.0'.DOMDocument40"); BEGIN XmlDoc := pXmlDoc; END; PROCEDURE SendMessage@1000000004(); BEGIN XmlDoc.loadXML('<root></root>'); END; PROCEDURE GetText@1000000001() : Text[50]; BEGIN EXIT(TextVar1); END; BEGIN END. } }
RegardsDo you make it right, it works too!2 -
garak,
WOW! It's a perfect method!
Especial respect from me!
Du bist ein Meister in Nav! :-({|=Nav 4.0 sp30 -
I agreed to fordewind its awesome.... =D> =D> =D> =D> =D>Sendoh
be smart before being a clever.0 -
garak wrote:when you need to update an Main Form from an Subform you can't do this with standard navision functions like Mainform.update. Ok you can use an Timer or an single insta. Codeunit, but this is an :-( solution. But why not using XMLDom -> M$ maked it possible ;-)
OBJECT Form 50000 Parent { OBJECT-PROPERTIES { Date=07-08-30; Time=15:14:11; Modified=Yes; Version List=; }...........
Regards
Perfect... but there's still a problem..
I can't use SendMessage() Function in OnAfterGetRecord of the subform.
It causes a runtime error, telling that object is not instanced!
How can I resolve this problem, avoiding a stupid timer?
I need that header updated everytime the user change from a line to another one.
Can u help me?
Many thanks.0 -
I had a similar requirement (hence finding your topic). I keep a running total and display this at the bottom of the subform, below the lines.
I added the following code to the subform :
OnInsertRecord
TotalLineAmount += Amount;
OnModifyRecord
TotalLineAmount += Amount-xRec.Amount;
OnDeleteRecord
TotalLineAmount - Amount;
I also added a function to the subform which initialises TotalLineAmount to the sum of the lines for the current mainform record. I called this from the OnAfterGetCurrRecord on the mainform.0 -
Can u explain me sir why we are using Automation for linking both the form0
-
All depends on where you are passing the automation from main form to the subform. May be that your trigger in the subform is called before the automation is passed from main to sub. Just add some flag variable which will tell you that the automation is already set and check it before you use the variable. That's all. The time line is critical in this... ;-)0
-
Anyone got the solution of sendoh working on RTC? I have tried but the event does not fire :-k0
-
garak wrote:But why not using XMLDom -> M$ maked it possible ;-)
However; we are unable to use it in document forms, when the column also is the last field in the tab-order.
I.e. we have a field on the header we would like to have updated when the Qty is entered in a Sales Order, but we would also like the focus go to the No. field on a new line. This is normally done by setting NextControl to a control placed before the current control. But due to the CurrForm.UPDATE(FALSE) on the main-form, then it jumps to the first line in the sub-form, instead of a new line.
Our quick and dirty solution was to include a field to the right of Qty in the tab-order. Then it works like a charm, but the user has to jump through one field more than he wish.
Not a big problem - just wondering if anyone solved this detail?Regards
Peter0 -
Hi, here is an alternative solution if you are able to register an extra DLL component on client side: https://github.com/serdarulutas/NAVAutomation .0
-
Since NAV 2013 R2 you can use Client Control Add-in to set up a javascript timer that triggers a NAV C/AL client side function on a page.
https://msdn.microsoft.com/en-us/library/dn182584(v=nav.71).aspx
Example :
Javacscript :function Refresh(){ Microsoft.Dynamics.NAV.InvokeExtensibilityMethod('Refresh', null); } function Activate(interval){ // interval in ms window.setInterval(Refresh, interval); }
C/AL :Refresher::ControlAddInReady() CurrPage.Refresher.Activate(100); Refresher::Refresh() IF SubPageHasChanged THEN UpdateAnOtherSubPage(); IF TimeHasCome THEN DoWhatNeedsToBeDone();
Of course this is very hacky, but it defenitely works, and AFAIK it's the only solution which works if one wants to trigger client side component like CurrPage.UPDATE or any function that needs to be running client-side.
Plus it can be useful if you want to trigger something at a given time (like an OnAfterOpen() function).
The main advantage compared to a classic Controll Add-In is that the DLL needs to be put only one time in the server Add-In directory, after that it will copy automatically on any client, including Web and Tablet.
The main drawback is that the controll add-in field must be visible and it takes up place, you can always put it out of a group at the end but there will be a short blank at the bottom. Maybe playing around with the css of the html generated by Microsoft could reduce it.0 -
That solution is awesome! Main form is updated instantly and no Times used! Thanks!when you need to update an Main Form from an Subform you can't do this with standard navision functions like Mainform.update. Ok you can use an Timer or an single insta. Codeunit, but this is an :-( solution. But why not using XMLDom -> M$ maked it possible ;-)
OBJECT Form 50000 Parent { OBJECT-PROPERTIES { Date=07-08-30; Time=15:14:11; Modified=Yes; Version List=; } PROPERTIES { Width=8000; Height=4840; OnOpenForm=BEGIN CREATE(XmlDoc); CurrForm.SubForm.FORM.SetXmlDoc(XmlDoc); END; OnCloseForm=BEGIN CLEAR(XmlDoc); END; } CONTROLS { { 1000000000;TextBox;330 ;220 ;4290 ;440 ;Editable=No; SourceExpr=TextVar } { 1000000001;SubForm;220 ;880 ;7480 ;2310 ;Name=SubForm; SubFormID=Form50001 } } CODE { VAR TextVar@1000000000 : Text[50]; XmlDoc@1000000001 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{88D969C0-F192-11D4-A65F-0040963251E5}:'Microsoft XML, v4.0'.DOMDocument40" WITHEVENTS; EVENT XmlDoc@1000000001::ondataavailable@198(); BEGIN END; EVENT XmlDoc@1000000001::onreadystatechange@-609(); BEGIN IF (XmlDoc.readyState = 4) THEN BEGIN TextVar := CurrForm.SubForm.FORM.GetText(); CurrForm.UPDATE(FALSE); END; END; BEGIN END. } } OBJECT Form 50001 Child { OBJECT-PROPERTIES { Date=07-08-30; Time=15:19:54; Modified=Yes; Version List=; } PROPERTIES { Width=8030; Height=2420; } CONTROLS { { 1000000000;TextBox;220 ;220 ;4180 ;440 ;SourceExpr=TextVar1; OnAfterValidate=BEGIN SendMessage(); END; } { 1000000001;TextBox;220 ;770 ;4180 ;440 ;SourceExpr=TextVar2 } } CODE { VAR TextVar1@1000000000 : Text[50]; TextVar2@1000000002 : Text[50]; XmlDoc@1000000001 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{88D969C0-F192-11D4-A65F-0040963251E5}:'Microsoft XML, v4.0'.DOMDocument40"; PROCEDURE SetXmlDoc@1000000000(pXmlDoc@1000000000 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{88D969C0-F192-11D4-A65F-0040963251E5}:'Microsoft XML, v4.0'.DOMDocument40"); BEGIN XmlDoc := pXmlDoc; END; PROCEDURE SendMessage@1000000004(); BEGIN XmlDoc.loadXML('<root></root>'); END; PROCEDURE GetText@1000000001() : Text[50]; BEGIN EXIT(TextVar1); END; BEGIN END. } }
Regards
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions