I have a form. Within the form I have a subform. Subfrom has two two primary key fields (FA No, Depreciation Book Code).
In the Header there is a field called FA Class Code. Whatever the user sets the FA Class Code to, it should automatically set a field in the subform (FA Posting Group) to the exact same thing. I was trying to do an implementation for this.
Code in "FA Class Code" onValidate trigger
FA.GET("No.");
//FADeprBook.SETCURRENTKEY("FA No.");
FADeprBook.GET(FA."No.");
FADeprBook."FA Posting Group" := FA."FA Class Code";
FADeprBook.MODIFY;
This code does not work, because I am using an GET statement, but i am only supplying it one of the primary key fields. I cannot put "Depreciation book code" because it doesnt exists in the header.
Is there a way of forcing the system to only consider one of the primary key fields? I tried the setcurrentkey, but that didnt work. Initially I was trying to do a setfilter (FADeprBook.SETFILTER("FA No.", FA."No.")) but that doesnt seem to do anything.
Header and the subform are linked by FA No.
I tried debugging it, and i found out that for some reason its not setting the FA No. in the subform (its always blank). But when I try using Ctrl+F8, i can see that is is set to the same FA No. as the header.
Any idea how I can do this??
Answers
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Also, there is only one issue with this code...lets say i set the FA class code to Building...it wouldnt show up in the fa posting group...but if i were to change the fa class code to something else....lets say Furniture...then the fa posting group would change to BUILDING. Its behind one for some reason if you know what i mean...
FADeprBook."FA Posting Group" := Rec."FA Class Code";
you are not running the onvalidate trigger that is in the table. So if there was some code it would not run.
When you call validate
FADeprBook.validate("FA Posting Group" ,Rec."FA Class Code");
if there was code onvalidate trigger in table it will execute the code. It is as though a user manually changing the field.
If there is no code in the table in the trigger onvalidate then onvalidate is the same thing as assignment.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Creating code or dataports or whatever in nav..you have to take into account all the other things going on behind the scenes. If there is code on the table behind that field your code won't execute it. therefore creating a future problem somewhere else. Just because it shows how you want in your current form doesn't mean it's correct everywhere in the system. and that's disaster down the road. be aware!
http://www.BiloBeauty.com
http://www.autismspeaks.org