Controlling text length coming from webform

logdoglogdog Member Posts: 12
Hello Everyone,
I have searched for this but not finding quite what I need. I have a webpage with a form on it that creates a csv file that gets imported to a NAV form (NAV 3.7a). One of the fields is an address. NAV limits the text length to 30 in the related address field. The problem is some people have an address that is longer than 30 characters that they are entering and when it gets imported we get a text to text overflow. I want to chop off anything after 30 characters before it enters the text field because I do not want to have to resize every address space throughout Navision.

Thank you for your time and effort

Comments

  • FishermanFisherman Member Posts: 456
    logdog -

    Look at using the DELSTR() function in combination with the MAXSTRLEN

    ex -
    MyColumn := DELSTR(MyVariable,MAXSTRLEN(MyColumn));
    
  • garakgarak Member Posts: 3,263
    and also possible, that you split the imported address. So you store the first part in Address field 1 and the second in address field 2. So the whole address will not cut (if the address on WebForm is max 60).

    Split example:
    If Strlen > 30 then find the last Space (or special charakter like , or ;) before 30 and store the lenght from 1 .. SpacePosition in address Field 1 and the second part in address field 2 (also only the lenght of the maxstrlen of the address 2 field)

    Regards
    Do you make it right, it works too!
  • kinekine Member Posts: 12,562
    Do not forget that you have triggers on the dataport item fields. On of them is OnBeforeEvaluate. It has one parameter, and it is the text read from the file. You can change it as you wish, after that it will be assigned into the variable. It means if you do something like:
    Text := FORMAT(Text,-MAXSTRLEN(MyVar));
    
    it will truncate the text to max length of the variable. If it is shorter, it will do nothing with the value...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.