Customer Card printing on Picking Sheet..

yuppicideyuppicide Member Posts: 410
edited 2009-11-19 in Navision Attain
Thought maybe I'd open a new topic for this. You might not have seen it since I posted it in an old topic of mine.

I have Nav 3.10. In the old topic you helped me add a Discount Comment to Customer Cards, that shows up on a Sales Header via FlowField. You can edit it on Customer Card, but only view it on Sales Orders. It does not print.

I'm not sure if my license allows it, but how would I get a field from Customer card to print on my Picking Sheet? I've created a new TextBox for "Invoice Instructions". I'd like to be able text into this field on the customer card and have it print out on the Picking Sheet.

Comments

  • DenSterDenSter Member Posts: 8,307
    in reports you need to do CALCFIELDS on flowfields.
  • rsaritzkyrsaritzky Member Posts: 469
    To be more specific, in the OnAfterGetRecord of the Sales Header dataitem in your picking ticket report, add a line that says:

    CALCFIELDS("Discount Comment");

    The field name should match whatever the flowfield name of the field in the Sales Header is, e.g. if it is called DiscountCommentFromCustomerCard, then you would enter CALCFIELDS(DiscountCommentFromCustomerCard);

    CALCFIELDS is used to trigger the calculation of a flowfield, which often is an arithmetic sum. In your case, it is just a "repeat" of information from the Customer table, but it still needs the CALCFIELDS command.
    Ron
  • DenSterDenSter Member Posts: 8,307
    In other words, when a flowfield is on the form, secretly the form does a CALCFIELDS before it displays the data. In all other objects you have to explicitly use CALCFIELDS.
  • rsaritzkyrsaritzky Member Posts: 469
    DenSter wrote:
    In other words, when a flowfield is on the form, secretly the form does a CALCFIELDS before it displays the data. In all other objects you have to explicitly use CALCFIELDS.

    Good clarification - I'm guessing that most beginning NAV programmers, when they first start creating objects, forget the CALCFIELDS a few times - at least I did <grin>...
    Ron
  • DenSterDenSter Member Posts: 8,307
    rsaritzky wrote:
    at least I did <grin>...
    It doesn't happen often, but I still do. I can look at something that is "broken" for a long time and never even consider that I made a rookie mistake... keeps you humble that :mrgreen:
  • yuppicideyuppicide Member Posts: 410
    Ok, so I've added Invoice Instructions to my Customer Card.

    I went into Picking List and into C/AL Globals. Added Invoice Instructions with a DataType of Record with SubType Customer.

    Added CALCFIELDS("Invoice Instructions") to OnAfterGetRecord.

    On Picking List I created a TextBox, but what do I put for SourceExpr? ="Customer"."Invoice Instructions"? ="Sales Header"."Invoice Instructions"?

    Anyway, If I try to compile it says "A field record variable was expected. For example: Record.Field Customer.Name" and it brings me to my OnAfterGetRecord section to fix whatever is wrong.
  • rsaritzkyrsaritzky Member Posts: 469
    OK, I think we may be talking apples and footballs here.

    Your first post said you added a flowfield to the Sales Header called "Discount Comment". If all you wanted to do was display the "Discount Comment" on the Pick List, and your pick list already includes the "Sales Header" record as a dataitem (e.g. standard pick list report 10153), then in the "Sales Header" dataitem's "OnAfterGetRecord", you would add the line

    CALCFIELDS("Discount Comment");

    NOW...

    If you're trying to add OTHER fields from the Customer Card OTHER than fields defined as flowfields on the Sales Header, you have to use a different technique - but it's not too difficult - you weren't too far off track on your last post - you were probably 90% right:

    "I went into Picking List and into C/AL Globals. Added Invoice Instructions with a DataType of Record with SubType Customer."

    It's a standard practice to create the global variable with a "logical name" of the actual record you're going to read. For me, I'd call the global variable "Customer" or "Cust", datatype Record, subtype "Customer" (you were right on the last two). Let's go with "Customer" for this example.

    Then, in the "Sales Header" dataitem's "OnAfterGetRecord" trigger, insert the line:

    Customer.GET("Sales Header"."Sell-to Customer No.");

    This will read the customer record with the Customer Number matching the Sales Header record's "Sell-to Customer No.");

    Now, after each Sales Header record is read, all the fields in the Customer Table are now available for printing.

    Create the textbox in the report, and in the "SourceExpr" property, put
    Customer."Invoice Instructions"

    This assumes the field on the Customer table/card is called "Invoice Instructions"

    Hope this helps.
    Ron
  • yuppicideyuppicide Member Posts: 410
    There must be something I'm not following right. It compiles now, but nothing prints.

    Added C/AL Global called Customer. We already have one called Cust.

    In sales Header we already have the following:

    Cust.GET("Sell-to Customer No.");

    It differs a little than what you wrote. But if I did try to enter what you wrote it won't compile, so I left yours out.

    On the report I did try entering what you suggested. Which was Customer."Invoice Instructions".

    It compiles fine, but nothing shows up.
  • yuppicideyuppicide Member Posts: 410
    On my Customer Table I have it listed as Data Type Text, Field Class Normal. Should that be something else like FlowField?
  • DenSterDenSter Member Posts: 8,307
    Cust.GET("Sell-to Customer No.");
    Cust.CALCFIELDS("Invoice Instructions";
    
    and in the section, the sourceexpr of the textbox: Cust."Invoice Instructions". I might be misunderstanding which field is a flowfield, so you might not need the CALCFIELDS in there. The point is, you have to use the right variable.

    Not 'Customer', not anything else, but 'Cust'. Remove all the new Customer variables and juse stick with the one already there, unless you have a need to get a customer that is not the Sell-to Customer on your order.
  • rsaritzkyrsaritzky Member Posts: 469
    yuppicide wrote:
    On my Customer Table I have it listed as Data Type Text, Field Class Normal. Should that be something else like FlowField?

    What is the actual name of the field in the Customer table that you want to print? Find it in the table designer layout, e.g. it should be something like:

    Field No. Field Name Data Type Length
    50001 Invoice Instructions Text 250
    Ron
  • yuppicideyuppicide Member Posts: 410
    Got it. Thanks for the excellent help. It only allows me to input 30 characters maximum.. I have to look into that, but all of the sudden got busy with other things.
  • SavatageSavatage Member Posts: 7,142
    yuppicide wrote:
    Ok, so I've added Invoice Instructions to my Customer Card.

    Take a quick look.
    Tools->Object Designer->Tables->Customer->Design

    Look at the field you added to the table, "Invoice Instructions"
    It's Type should be TEXT & it sounds like it's length is 30
    yuppicide wrote:
    It only allows me to input 30 characters maximum
  • rsaritzkyrsaritzky Member Posts: 469
    Looks like you're almost done. Harry is right - seems like you set the length of the new "Invoice Instructions" field to 30, which is the default length when you select a field type of "text".

    Just increase the field length to 80 or whatever you want.

    Then, on the customer card, you may want to change the size and shape of the textbox with this field in it. Change the "Multiline" property to "Yes" and make the box "taller", and then your instructions will wrap within the box. Or, you can leave it the same size and the field will just "scroll" within the single-height textbox.
    Ron
  • yuppicideyuppicide Member Posts: 410
    I figured it out. Somehow the "Length" column was hidden when I went into Customer Table to add my field. In there the length was locked to 30 characters even though on my TextBox it was set to allow 80.
  • rsaritzkyrsaritzky Member Posts: 469
    Yes - when you put a database field on a form, the allowed length is based on the database field properties, not the textbox properties.
    Ron
  • SavatageSavatage Member Posts: 7,142
    yuppicide wrote:
    even though on my TextBox it was set to allow 80.

    Where is that setting in a textbox? Unless you're talking about creating a global variable?
Sign In or Register to comment.