I've created a field in the table "Cust. Ledger Entry" (Yes, I know I shouldn't...). Its value depends on the value of several fields of the same record and of other records from the table. How can I make its calculation automatic, every time a record is inserted?
Note: Since this table is updated by several forms, I would rather insert C/AL on the table itself...
Regards,
Manuel Xavier
0
Comments
Just make a seperate procedure (in which you make the calculation) in your Cust. Ledger Entry table, and call this procedure in the OnModify and OnInsert (mostly at the end) trigger.
If this doesn't do the job (When the code does INSERT(FALSE) on the Cust. Ledger Entry table, the OnInsert trigger isn't triggered and your procedure will not be called), you might think of calling the procedure on the OnValidate-trigger of every relevant field.
You also mention the value depends on other records in the same table ... well, in your seperate procedure, you can make a record-variable of the table you're working in.
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
What can it be?
Manuel Xavier
you could use code coverage for this ...
sorry I can't be a bigger help ...
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
You'll have to look in codeunit 12, probably specifically to the PostCust-procedure.
Please let me know if you succeeded.
Good luck!
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
One more question, what's code coverage?
It is my 1st time working with navision...
Manuel Xavier
When you start, the form starts to list all code executed, until you press stop. Afterwards you can go through the executed code.
Just play with it, and it will be clear right away ... .
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
I was able to run my code using the codeunit 12...
Manuel Xavier
Freelance Dynamics AX
Blog : http://axnmaia.wordpress.com/
If you don't have to filter on the field, this means it's only a field the user want to see on the form, you could just add a new label and tablebox to you form and type a formule in the source expression of this field.
If it was hard to write, it should be hard to understand."