wont set one field!
nverma
Member Posts: 396
Could someone look at the following code and tell me what I am doing wrong. The line that has a bunch of stars with them, it wont execute it. It pulls the correct FA Class code and it sets the correct no. of depreciation year in the depreciation book form, but it wont set the correct depreciation method field. Any idea why???
This code is written in OnValidate trigger (FA class code)
FAClass.Depreciation method is an option field and FADerpBook."Depreciation Method" is also an option field.
This code is written in OnValidate trigger (FA class code)
FA.GET("No.");
FADeprBook.SETRANGE("FA No.", FA."No.");
FASetup.GET;
//FAClass.GET;
IF FADeprBook.FINDSET THEN
IF FASetup."Default Depr. Book" <> '' THEN
BEGIN
FADeprBook.SETRANGE("Depreciation Book Code", FASetup."Default Depr. Book");
IF FADeprBook.FINDFIRST = TRUE THEN
IF xRec."FA Class Code" = '' THEN
BEGIN
FADeprBook."FA Posting Group" := Rec."FA Class Code";
FAClass.SETFILTER(Code, Rec."FA Class Code");
IF FAClass.FINDSET THEN
REPEAT
FADeprBook."No. of Depreciation Years" := FAClass."Default Years"; // WORKS Perfectly
FADeprBook."Depreciation Method" := FAClass."Default Method"; //************* DOES NOT WORK
UNTIL FAClass.NEXT = 0;
END
ELSE
IF CONFIRM ('Do you want to change the FA Posting Group on Depreciation Book %1?', TRUE, FASetup."Default Depr. Book") THEN
BEGIN
FADeprBook."FA Posting Group" := Rec."FA Class Code";
FAClass.SETFILTER(Code, Rec."FA Class Code");
IF FAClass.FINDSET THEN
REPEAT
FADeprBook."No. of Depreciation Years" := FAClass."Default Years"; // WORKS Perfectly
FADeprBook."Depreciation Method" := FAClass."Default Method"; //************* DOES NOT work.
UNTIL FAClass.NEXT = 0;
END
ELSE
Rec."FA Class Code" := xRec."FA Class Code";
END;
FADeprBook.MODIFY;
FAClass.Depreciation method is an option field and FADerpBook."Depreciation Method" is also an option field.
0
Answers
-
Nevermind, I found the solution to the problem. What had happened was, I added an additional option to the Depreciation method in the fa depreciation book table, but i didnt add it to the default method in the FA Class table
That is why it was messing it up.0 -
I'll take a guess that FADeprBook."Depreciation Method" is an option type,
and you have an option issue.
edit::When adjusting option fields like adding values, you have to find where else in the system they are used else you can cause yourself an error due to a mismatch.0 -
This is sorta off topic,but I have a generic question:
I know that GET statement fetches the primary keys of the table. Lets say the Primary Key of the Table (lets call the table 'FA') is: FA No. & FA Depreciation Book Code
Can someone clarify the difference between these 3 statements:
1) FA.GET;
2) FA.GET (FAdeprBook."No.");
3) FA.GET (FAdeprBook."No.", FAdeprBook."Depreciation Code");
I know it a silly question, but I just want this clarification before I misunderstand the concept.
i know the concept, i just want to make sure what I know is the correct...0 -
By asking this question, you prove that you DON'T understand the concept.nverma wrote:i know the concept
You use GET to retrieve one and only one record from the database, for which you know all of the primary key values. If you don't know all of the primary key values, and you still use GET, you are using the wrong keyword.0 -
What happens if I only provide the GET statement with only one of the primary key fields and also what happens if i dont provide any of the fields.
1) FA.GET (FAdeprBook."No.");
2) FA.GET;0 -
Just don't use it like that.
If you don't have all primary key values, you set filters and you use one of the FIND statements (FINDFIRST, FINDLAST, FINDSET) to retrieve the records.0 -
I'm sure I gave you these links before.
Add them to your favorites.
http://msdn.microsoft.com/en-us/library/dd301056.aspx
http://msdn.microsoft.com/en-us/library/dd3550320 -
Do you think someone will read these links?Savatage wrote:I'm sure I gave you these links before.
Add them to your favorites.
http://msdn.microsoft.com/en-us/library/dd301056.aspx
http://msdn.microsoft.com/en-us/library/dd355032
If yes, they never ask basic technical questions. :thumbsdown:0 -
nobody bothers reading manual these days
Microsoft Certified IT Professional for Microsoft Dynamics NAV
Just a happy frood who knows where his towel is0 -
Read my Lips :thumbsup:dans wrote:nobody bothers reading manual these days
0 -
I'd rather read a manual than reading your lips :P.mohana_cse06 wrote:
Read my Lips :thumbsup:dans wrote:nobody bothers reading manual these days
The usual steps for calling help should be
a: is it a tech question or a business question?
b: for tech questions: is it beginner, advanced or exotic?
Beginner: F1, Advanced: Manual, Exotic: Mibuso \:D/0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

