calculate a field lenght while typing

aldarionaldarion Member Posts: 24
edited 2004-09-08 in Navision Attain
hello,

I'm trying to put a message any time the lenght description of a sales line become greater than 60 characters (the description accept 100 in the database). But I don't find where navision "stocks" the variable before changing the record.

can anyone help?

Comments

  • OliverTOliverT Member Posts: 37
    i don't know any trigger which could manage something like this :(
  • aldarionaldarion Member Posts: 24
    well I use the oninputchange trigger on the form but the rec is not modified every time you hit the keyboard so I'm a bit stuck
  • Dean_AxonDean_Axon Member Posts: 193
    i'd been trying all those options too whilst waiting to post and came up with no answer either.

    as for Navision "Stocking" the variable the only way I could do any kind of STRLEN check was on validate. This wont help you though on the checking whilst your typing :!:

    What is the reason behind the 60 characters ??? Is it that you only want to allow entry of 60 characters and then append something to the description that takes a further 40 ??? If so , you could always use a variable with max length of 60 characters and then commit this with your addition to the description field :D

    let us know soon .
    Remember: Keep it simple
  • aldarionaldarion Member Posts: 24
    :oops: No it is just a reason of appearance on reports. I know it's stupid and it will be much easier to modify the report layout but it seems it will be ugly and as the report is to be sent to customers. So they just want a warning telling that after that number of character some info will not be shown on the report.
  • Dean_AxonDean_Axon Member Posts: 193
    In that case... EASY SORTED :D:D:D

    Make a variable that only allows 60 characters and transfer that to the Description field using the "OnAfterValidate" trigger of the field on the form.

    This way no modification is needed to the description field on the table OR form and your report will look ok :wink:

    or if you want to look really clever, create a new section of the report with an alternative layout. in the "onePreSection" of that section on the report do something like this:
    CurrReport.Showoutput(Strlen(Description)>60);
    

    so this means you will have two sections to show line information but you can have two layouts that will format the report layout as you would like to show it :D
    Remember: Keep it simple
  • OliverTOliverT Member Posts: 37
    what do you think about this solution:

    - create a new dataitem (using table 2000000026 as dataitemtable) ... this dataitem should be a "child" of the dataitem with the discription ;)

    - create a new global named smalldescription or something else (type: text, length: 100)

    - add a new section (type: body) for the new dataitem in your report

    - code the following in onpredataitem:
    if strlen(description) > 60 then
      setrange(number,1,2)
    else
      setrange(number,1,1);
    
    - code the following in onaftergetrecord:
    if number = 1 then
      smalldescription := copystr(description,1,60)
    else
      smalldescription := copystr(description,61,100);
    
    - now add a field to the new section with the sourceexpr 'smalldescription'

    i think this will work ... :roll:
Sign In or Register to comment.