Another report question to display data!

nverma
Member Posts: 396
Sorry to bother you guys again. But I have another question. This is what I have to do: -
The Health Card No. appears on BOTH the Job and Consumer Cards. So which do we use? As always, exercise caution and assume nothing. Here’s what you should do: If the Job card has a Health Card No. defined, then retrieve it from there. If it doesn’t, then check the Consumer Card. If the Consumer Card does, then show that value. Otherwise, leave the Health Card No. column in the report as blank, but show the rest of the info anyway (as I mentioned above).
HealthCard is a variable I created which is of type text.
This is the code I wrote for it: -
How do I get the report to go through this code for every single Job No. and to display the result accordinly.
The Health Card No. appears on BOTH the Job and Consumer Cards. So which do we use? As always, exercise caution and assume nothing. Here’s what you should do: If the Job card has a Health Card No. defined, then retrieve it from there. If it doesn’t, then check the Consumer Card. If the Consumer Card does, then show that value. Otherwise, leave the Health Card No. column in the report as blank, but show the rest of the info anyway (as I mentioned above).
HealthCard is a variable I created which is of type text.
This is the code I wrote for it: -
IF Job."Health Card No." <> ' ' THEN HealthCard := Job."Health Card No." ELSE HealthCard := Customer."Health Card Number";
How do I get the report to go through this code for every single Job No. and to display the result accordinly.
0
Answers
-
Where did you try this code?0
-
This code is written in OnAfterGetRecord.
I wrote this code after reading the instruction that I posted in the first post.0 -
If you want it to check on each record the put onaftergetrecord.
If your dataitem is job you'll have to use Customer.GET(.....) before Customer."Health Card Number";
Now you could either use it before all your if statments or include it with in using "then begin" instead of just "then".0 -
Customer.GET("Health Card Number") IF Job."Health Card No." <> ' ' THEN HealthCard := Job."Health Card No." ELSE HealthCard := Customer."Health Card Number";
Right now, it just displays the Health Card No. that is in the job card. It doesnt even check the Customer Card. How do I make check customer card if the Job card is empty. and if customer card has a health card number. I want it to display that number.0 -
GET doesn't work like that - You need to GET the primary key field of the customer table and "health care card" is not it! Read Here:
http://msdn.microsoft.com/en-us/library/dd301056.aspx
We don't use jobs so I don't know the actual field names but it should be something like thisIF Job."Health Card No." <> ' ' THEN begin HealthCard := Job."Health Card No."; end ELSE begin if customer.get(job."Customer No.") then HealthCard := Customer."Health Card Number"; else HealthCard := ''; end;
0 -
Why do we need to do this statement???
if customer.get(job."Customer No.").
What are you basically trying to do???0 -
Did you read the link above?
How do you plan on getting a record from the customer table?
If you don't use GET the value you show for Customer.anything will be blank.0 -
I did read it.
But the part I was confused with is:-
(job."Customer No.")
Why would I need to look at Job. shouldnt it just be a primary key in the customer table such as No.
so shouldnt it look like this.
if customer.get("No.")0 -
We don't use jobs so I don't know the actual field names but it should be something like this
As i stated above, I don't use JOB's so my field names might not be correct but I would hope you were getting the idea of what field should be used.
So I typed Customer.GET(job."Customer No".) hoping that if that was not correct that you would replace job."customer no." with the JOB field that DOES hold the customer's number.
Also, in your previous post I mentioned downloading & printing the application Designers Guide.
This guide has a section on reports, how to build them, How to use GET, what the triggers do.
So this would be a very valuable tool for you and many of your problems you will be able to handle yourself.
By using GET you are telling the system which customer record to get else how would it know which customer health card number it should retrieve?
And by using IF with GET we are avoiding runtime errors.0 -
It actually works.
I am still a little confused about using GET, FIND, SETRANGE, etc
I have gone over the explanations that microsoft has given for each of them numerous times, but they still didnt sink in with me completely.
Is There a PDF or any other source you guyz might know that might, shows how to use these in multiple way OR can give a better explanation for each of them...so I can get this concept.
Knowing this concept is a MUST if I want to work with NAV.0 -
I will print it out and go over the book.
Thank you so much.
If I think about it, it does make sense. Since I am new to NAV, its taking a while to sink in.
I will definately go over this book to hammer this concept out.0 -
since you have a field that holds the value that matched the primary key of the table you are trying to retrieve then GET works. Say you had just the customer name, then you could use setrange/setfilter & find to narrow down the choices on the customer table (for example)0
-
nverma wrote:It actually works.
Edit your first post and change the attribute to "Solved"0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions