Another report question to display data!

nvermanverma 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: -
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.

Answers

  • nvermanverma Member Posts: 396
    This code is written in OnAfterGetRecord.

    I wrote this code after reading the instruction that I posted in the first post.
  • SavatageSavatage Member Posts: 7,142
    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".
  • nvermanverma Member Posts: 396
    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.
  • SavatageSavatage Member Posts: 7,142
    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 this
    IF 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;
    
  • nvermanverma Member Posts: 396
    Why do we need to do this statement???

    if customer.get(job."Customer No.").

    What are you basically trying to do???
  • SavatageSavatage Member Posts: 7,142
    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.
  • nvermanverma Member Posts: 396
    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.")
  • SavatageSavatage Member Posts: 7,142
    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.
  • nvermanverma Member Posts: 396
    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.
  • nvermanverma Member Posts: 396
    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.
  • SavatageSavatage Member Posts: 7,142
    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)
  • SavatageSavatage Member Posts: 7,142
    nverma wrote:
    It actually works.
    =D>
    Edit your first post and change the attribute to "Solved"
Sign In or Register to comment.