Subform/sub-table called func. doesn't refresh main form

NickA
Member Posts: 32
Hi,
I'm an experienced programmer but haven't written a lot of Navision code recently (I'm a bit rusty).
For a customer, I've added a new field to the sales header table called 'Credit Hold'. It's an option field with the values 'good', 'held', 'released'.
The concept is if the customer has a credit problem, rather than just warning the user the 'Credit Hold' field gets set to 'Held'. Posting isn't allowed until someone releases it.
Problem is, Entering a sales order, when I call my new credit checking routine from the 'Sales Lines' table (to check a modified line hasn't caused a credit problem) the 'Credit Hold' field is set to 'Held' on the record BUT crucially the main form doesn't automatically update - it only updates to the new value when I click on the form to give it focus.
As the function is being called from within the 'Sales Lines' table I can't just call a <FORM>.REFRESH.
I'm doing something stupid I just know I am, can anybody help?
I'm an experienced programmer but haven't written a lot of Navision code recently (I'm a bit rusty).
For a customer, I've added a new field to the sales header table called 'Credit Hold'. It's an option field with the values 'good', 'held', 'released'.
The concept is if the customer has a credit problem, rather than just warning the user the 'Credit Hold' field gets set to 'Held'. Posting isn't allowed until someone releases it.
Problem is, Entering a sales order, when I call my new credit checking routine from the 'Sales Lines' table (to check a modified line hasn't caused a credit problem) the 'Credit Hold' field is set to 'Held' on the record BUT crucially the main form doesn't automatically update - it only updates to the new value when I click on the form to give it focus.
As the function is being called from within the 'Sales Lines' table I can't just call a <FORM>.REFRESH.
I'm doing something stupid I just know I am, can anybody help?
0
Comments
-
AFAIK what you want to do is not possible.
But I will sure check out this thread for possible solutions as I do not now any and have been in a similar situation numerous times.
Your sub-form has the focus and through C/AL there is no way to access the parent form as you have also found out and since you can't do that your are *busted*.Best regards
Tommy0 -
The concept of solution would be:
Your changes should start a trigger on a main form, calling a subforms perform a change, then when returning to main form trigger checking for update.
Like using button "Line"."Item &Tracking Lines" which triggers:
CurrForm.SalesLines.FORM.OpenItemTrackingLines;
After that the control is returned to main form's trigger.
Since your changes doesn't start trigger on main form, but rather on subform, this is not possible to trigger it.
but, you can have a code in timer event of main form, that checks if there are any changes of the status (checks should be done on local rec var)OnTimer IF lrSH.GET("rec.Document Type",rec"No.") THEN BEGIN IF lrSH."MyStatus" <> rec."MyStatus" THEN CurrForm.UPDATE(FALSE); END;
This is not nice and you should avoid it (especially with a lot of users), but it should do the job.
Second option is to make a new menu item on form that just calls CurrForm.UPDATE(FALSE); and link it to ShortCutKey. It's not automatic, but it's quick and user knows what to do to check last status.®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0 -
Thanks for the help, both of you.
I'll see what customer feedback there is and probably implement the 'timer' solution.0 -
There is a neat way of achieving this as well using a DLL wich has a callback trigger. The drawback for this solution is that you will have to distribute a DLL to every client. However, this is how it could work:
1.1. Create DLL
1.2. Add event "CallBackTrigger"
1.3. Add public sub "CallBackParent"
1.4. Raise the event "CallBackTrigger" in the "CallBack" Sub.
2.1. Create a global var "pCBdll" on the subform (NOT withevents!) that points to your class in the DLL
2.2. Create function "SetCBdll" in subform with a "VAR" parameter "plCBdll" that points to your class in the DLL.
2.3. In that function set global var to the parameter var
(pCBdll := plCBdll)
2.4. At the point(s) in the subform where you want the main form to be updated call "plCBdll.CallBackParent"
3.1. On the main form create global var "CBdll" (withevents) that points to the class in your DLL
3.2. In the OnOpenForm Call "SubForm.SetCBdll(CBdll);"
3.3. You will see the trigger "CallBackTrigger" on your form. This trigger will execute each time you call "plCBdll.CallBackParent" in your subform.
3.4. Call your updating function here
Just a neat trick.
But, oke ... sometimes the solutions are more difficult then the problems...
Maybe i'm not realistic anymore ...
And who can program VB these days ... :roll:In a world without Borders or Fences, who needs Windows and Gates?0 -
You could also include your credit check in the sales order release function. You should only be able to post a released SO anyway, so in order to be able to post, the user has to release the order first.0
-
You could also include your credit check in the sales order release function. You should only be able to post a released SO anyway, so in order to be able to post, the user has to release the order first.
A 'Credit Held' order is checked and possibly released by somebody with appropriate privileges - so under certain circumstances somebody will release the order from the credit hold and allow it to be fulfilled even if the customer hasn't done anything to resolve the credit issue.
If I ran my credit check again during 'Release' it would put the order straight back on credit hold.0 -
NickA wrote:A 'Credit Held' order is checked and possibly released by somebody with appropriate privileges - so under certain circumstances somebody will release the order from the credit hold and allow it to be fulfilled even if the customer hasn't done anything to resolve the credit issue.
If I ran my credit check again during 'Release' it would put the order straight back on credit hold.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