Hallo All!
exuse for my English, it's not so good but I try to explain the problem in the understandable way
I added new boolean field on the table 37 sales line. This field shows is the cost adjusted for line item or not. It's not the standard NAV cost adjustments, it is additional functionality which determines the value of this field through few different tables (Item, Sales Shipment Line, Item Ledger Entry, Item Application Entry). It is the reason why I can't make this field as a simple FlowField. Purpose of this field is possibility to filter sales order (subform) and see which lines are adjusted and which aren't. The problem is that the new field should be updated each time I run the sales order.
If I call my function (which updates this field for current line) from sales order subform - OnAfterGetRecord trigger and function does not modify sales line - the value of new field is showed correctly on the form but still equal to old value in the table. So the filtering is not possible because table is not modified with new values.
If the function tries to modify sales line the standard trigger error appears ("you cannot make any changes to the database in this trigger").
Now I don't see any solution...
The only way is add the new button to call this function manually and update the subform. But it's inconveniently for my needs.
Navision version: 3.7 NA
Thanks In advance
Comments
Maybe it's me but I don't know what this means.
In your function are you specifing the Doc Type Doc No & Line No so it knows which one to update?
What's the code?
http://www.BiloBeauty.com
http://www.autismspeaks.org
the function is called from sales order subform, OnAfterGetRecord trigger
Function SetCostAdjustment it works with the rec of subform so I don't need to specify Doc Type, Doc No & Line No
as you can see there is no MODIFY expression
after opening sales order I have the set of records on the subform where Cost Adjusted is calculated right.
but, if I find these records in the table 37 the Cost Adjusted field will be set to No. in all of them
and I can't filter sales lines by this field because it isn't filled in table
if I place MODIFY into my function the trigger error ("you cannot make any changes to the database in this trigger") appears
Hi
Add a menu option "Update Adjusted Cost" on "Function" button.
I think it isn't another solution.
Matteo
but as I wrote in my first message adding a button/menu button is inconveniently. It's possible and easy way but it sholud be updated automatically...
Well you're not really running a sales order. Just getting a field is not going to let to change it in this way.
http://www.BiloBeauty.com
http://www.autismspeaks.org
solution I often use is:
in OnAfterGetRecord put statement
SAVERECORD;
and calling your code put in ONMODIFY trigger.
Hi, I tried this solution. When I opened sales order the confirmation message appeared:
Do you want to rename the rocord?
If I pressed Yes - I saw the error message:
You cannot rename a Sales Header.