I wanted to setup a default value to a field, everytime a fixed asset card was created.
After doing a bit of searching on the form, i found out that doing it the INITVALUE is not really a good way of doing it. So I tried doing it the way you guyz suggested it. I went to FASetup table and card and created a new field called Default Depr Book code and I also set the table realation in the fa setup table to the depreciation book table.
In the field I want it to display 'OMOD' as soon as a fixed asset card is created.
At first i tried to do it in the FA Card Header onInsert (trigger) but that didnt work, because the FA card has to be created first, then only I can do some calculations on it. So then I tried setting it up onInsertRecord (trigger) in the subfrom, but that didnt work aswell. What am i doing wrong??
Code in the subfrom tigger:
FASetup.TESTFIELD("Default Dep. Book Code");
FADeprBook.INIT;
FADeprBook.VALIDATE("Depreciation Book Code", FASetup."Default Depr. Book");
FADeprBook.VALIDATE("FA No.", Rec."No.");
FADeprBook.INSERT;
Any idea what I might be messing up on???
Comments
You have to think your way through the problem. Take it one step at a time.
Step 1: a default value needs to be populated when a fixed asset card is created. The point at which any record is created is in OnInsert of the table. You want it on the fixed asset card, so that would be the "Fixed Asset" table.
Step 2: The value comes from the fixed asset setup table, for which you've created a default field -> good
Step 3: Now you need to create a "FA Depreciation Book" record.
Step 3a: Figure out how this works. Turn on the debugger, and create one by hand. Write down what happens.
Step 3b: Figure out how that relates to the Fixed Asset record, make sure you understand the link.
Step 4: Now you know WHERE to write the code, and you've written down HOW it happens. From there it's just a matter of writing the proper C/AL code.
Step 5: TEST
It looks like you're on the right path, but forget about EVER writing data code like that on forms.
RIS Plus, LLC
RIS Plus, LLC
:thumbsup: :thumbsup: