Form field - behind the "scenes"

CobblerCobbler Member Posts: 16
Hi All,

I'm a very beginner, so sorry for this trivial question.
I need to redesign a form, because it has two fields integer. But I have to type floating point numbers (Decimal type in Navision).

So when I want to type this: 130.42
I get an error message: You cannot enter '130.42' in Integer. So I'd like to modify the source data to Decimal. But how can I know what is the source table of that form to modify appropriate field types?
Anyway this form is the Sales Order (Fields: Gross weight and Net weight).

Thank you in advance!

Comments

  • tinoruijstinoruijs Member Posts: 1,226
    Modify the form. Go to the property SourceTable.
    In that table you probably will find the fields you want to modify.

    I say Probably because it can also be fields in another table. For example item."Gross Weight" in the sourceexpr of the field Gross Weight on the form.

    And you have to look where the fields are used and see if the change effects the current functionality.

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • CobblerCobbler Member Posts: 16
    I checked the Sales Line table. This table contains the Gross Weight and net Weight fields. I modified the decimal places of these field from 0:5 to 1:5. So theoretically I will able to type '130.6' on Sales Order form.
    But when I do this I get the same message: You cannot enter '130.6' in Integer.
    I don't understand this, because the type of those fields is not Integer. it is Decimal.
  • tinoruijstinoruijs Member Posts: 1,226
    You could use debugger to see where the error is giving.
    You probably end up in a customized object/function.

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • Dave_CintronDave_Cintron Member Posts: 189
    Sounds like the weight fields are Integers, change the Data Type to Decimal.
    Dave Cintron
    Dynamics West
    http://www.dynamicswest.com
  • CobblerCobbler Member Posts: 16
    Yes it is maybe an Integer. But no, because the basic data are in the Sales line table. And there the type is decimal.

    So I think tinoruijs is right. Somewhere might be a customized function, that checks the value.

    So I tried to debug the form, but the debugger went to a neverending loop. Therefore I couldn't find out what is that function.
  • tinoruijstinoruijs Member Posts: 1,226
    Maybe you can find it out by using Code Coverage?

    I would start by looking in the OnValidate of the fields in the Sales Line table.

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • CobblerCobbler Member Posts: 16
    I checked them. There's nothing.
  • tinoruijstinoruijs Member Posts: 1,226
    Cobbler wrote:
    I checked them. There's nothing.

    Ok. And you have tried Code Coverage?

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • CobblerCobbler Member Posts: 16
    Okay, I found the fields in the Sales Header table. And the "incorrect" Integer datatypes.

    But a new problem was born :)

    I can't modify the datatype to decimal. Because firstly I have to reset the appropriate field values to 0 or ' '.
  • tinoruijstinoruijs Member Posts: 1,226
    Cobbler wrote:
    Okay, I found the fields in the Sales Header table. And the "incorrect" Integer datatypes.

    But a new problem was born :)

    I can't modify the datatype to decimal. Because firstly I have to reset the appropriate field values to 0 or ' '.

    You are working on a live-database I assume?
    Then you need to make a report or codeunit that transfers the data in the integer-fields to (temporary) decimal or integer fields in the same table. And empty the integer-fields you want to convert to decimal.
    Next convert the integer-fields.
    Next transfer the data from the temporary fields to the converted decimal-fields.
    You have to decide if it's needed to use VALIDATE on the fields. So if you want to execute the code that's in the OnValidate of the fields.
    But you already said there's nothing there, so it's not needed then.

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • CobblerCobbler Member Posts: 16
    Firstly I do the changes in a test database. And if everything works I do it in the live-db as well.

    I exported the two columns with dataport. But how can I make empty that columns in the table?

    Do I have to make a function or does a command exist for this?
  • tinoruijstinoruijs Member Posts: 1,226
    Cobbler wrote:
    Firstly I do the changes in a test database. And if everything works I do it in the live-db as well.

    I exported the two columns with dataport. But how can I make empty that columns in the table?

    Do I have to make a function or does a command exist for this?

    You need to make a report or codeunit that transfers the data in the integer-fields to (temporary) decimal or integer fields in the same table. And empty the integer-fields you want to convert to decimal.

    Create report for table.
    In OnAfterGetRecord:
    newtempfield := integerfield;
    integerfield := 0;
    MODIFY;

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • CobblerCobbler Member Posts: 16
    I can't believe this...

    I exported the field values with dataport.
    I successfully delete values from appropriate columns.
    I create a dataport for importing.

    When I run this dataport, the progress bar is running and running, so it seems everything works well. But in fact values didn't imported. What could be the problem with my method?! ](*,)
  • DenSterDenSter Member Posts: 8,305
    I don't want to offend anyone, but you really should get your partner involved.

    Also you need to get some basic development training and learn about database structures, then learn about how things are done in NAV properly. Training classes are probably out of the question, so I'd suggest you get David Studebaker's NAV development book, and work through the exercises. If that is too difficult then get a book that tells you about basic database design.
  • tinoruijstinoruijs Member Posts: 1,226
    For this kind of processing a report or a codeunit I find the best approach.
    So not a dataport.
    Maybe the problem is a missing MODIFY or the properties in the dataitem of the dataport?

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • CobblerCobbler Member Posts: 16
    DenSter:

    So you suggest for every beginner, don't visit this forum, and don't make any notes, until not read any training books.

    I feel this note was a little discriminative. I assume you also was a beginner once, unless you were born with Navision programming knowledge...

    But it doesn't matter.
    Thanks for the others especially to Tino.
Sign In or Register to comment.