Extremely new to NAV - Need form textbox help

c_sledgec_sledge Member Posts: 10
Hi guys,

I'm brand new to NAV dev, and I have a specific goal I'd like to achieve.

I have a report, that has 3 separate, named, textboxes I'd like to change the text of based on what a user specifies in an option field on a record in a table.

So, lets say the user enters a record and picks option A.

Out of the three textboxes on the form, I need one of those to update to something such as 'X' on the report to indicate that specific option was chosen, while leaving the other 2 textboxes blank.

I understand there will be variables involved, but I'm unsure how to link a variable to the textboxes, nor how to have the code reference the field from the record to execute a function to perform this.

I'm assuming this also could take place in a trigger, but I'm unsure of the best method to achieve such functionality.

I'm sure this is extremely easy for some of you out there, and I apologize upfront for the lack of knowledge. If you need more information, please let me know.

THANKS!

Comments

  • SavatageSavatage Member Posts: 7,142
    There's probably multiple ways of doing this. here's a quick test

    create a report using sales header as the dataitem.

    global var: MYDOCTYPE -> TYPE TEXT

    OnAfterGetRecord()
    IF "Document Type" = "Document Type"::Order
    THEN MYDOCTYPE := 'o' ELSE MYDOCTYPE := 'x';

    Add a text box to a report with sourceexp MYDOCTYPE
    change the font to Wingdings. also add an order numbe field.

    Print preview.

    You will see a box next to all Order Numbers that are type Order and a box with an "x" for all other types.

    just a sample - you can expand on this to fill your needs. Perhaps even use a "case" statement for all yur options.

    There is a Application Designers Guide that comes with your product cd to help you with reporting(w1w1adg.pdf).

    http://www.microsoft.com/download/en/de ... n&id=24432
    http://msdn.microsoft.com/en-us/library/dd301468.aspx
  • c_sledgec_sledge Member Posts: 10
    Thanks very much for the reply.

    I'll go through the documentation and see what I can come up with.

    I very much appreciate it.
  • c_sledgec_sledge Member Posts: 10
    Alrighty,

    So i've gotten your proof of concept to work. Now I'm trying to carry something similar over to the actual existing report.

    I've created the globals, the textboxes, set the source expressions and added the following code to the OnAfterGetRecord trigger in the header code, where this needs to be displayed.
    PrepaidText := "";
    ThirdPartyText := "";
    CollectText := "";
    
    IF "Freight Billing" = "Freight Billing"::Prepaid THEN
      PrepaidText := 'X'
    END
    
    IF "Freight Billing" = "Freight Billing"::ThirdPartyText THEN
      ThirdPartyTextt := 'X'
    END
    
    IF "Freight Billing" = "Freight Billing"::CollectText THEN
      CollectText := 'X'
    END
    

    The field name from the table is Freight Billing, but upon trying to compile, I get a 'FieldNo must not be blank error'. Nothing else in the trigger code has been changed.

    Any thoughts on where I'm going wrong?

    Thanks.
  • SavatageSavatage Member Posts: 7,142
    You can clean it up with a case statement - case statements are great for options
    2nd..you have "Freight Billing"::ThirdPartyText is ThirdPartText the ACTUAL option?
    CASE "Freight Billing" OF 
      "Freight Billing"::Prepaid : 
        PrepaidText := 'x';
      "Freight Billing"::"Third Party":
        ThirdPartyText := 'x';
      "Freight Billing"::"Freight Collect"
        CollectText := 'x';
    END;
    

    ps i think the x box is the lowercase wingdings "x"

    or you can avoid getting fancy & just the print the option chosen in text at the top of the report just like the other filters & reports
Sign In or Register to comment.