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?
0
Comments
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*.
Tommy
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)
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.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
I'll see what customer feedback there is and probably implement the 'timer' solution.
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:
RIS Plus, LLC
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.
RIS Plus, LLC