Not allow specific value in item decription field

cwigintoncwiginton Member Posts: 16
Hello,
I need to find a way to stop my users from entering " and , into the item desription field. We have to periodically export to a .csv file and these values are causing problems. Any advise would be greatly appreciated.

Thanks

Comments

  • matttraxmatttrax Member Posts: 2,309
    So essentially you need to parse your text before saving it to the database.

    Look into STRPOS which will help you search for a specific character, and COPYSTR, which will let you take substrings. DELCHR might also help.
  • SavatageSavatage Member Posts: 7,142
    if you use STRPOS to search the string for the characters you want and it returns a value of anything but zero then it exists.

    another way is to determine the allowable characters

    txtAllowedChars := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; // string with all allowed characters
    vDescription := DELSTR(Description,'=',txtAllowedChars);
    IF vDescription <> '' THEN ERROR('Characters "%1" are not allowed',vDescription);
  • ara3nara3n Member Posts: 9,256
    Another solution is to not export it as csv, but as TAB delimited and the only value they cannot enter is TAB which is not possible to enter manually in NAV.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • ara3nara3n Member Posts: 9,256
    another solution is to just add code to remove " when they enter it.

    The following code onvalidate
    Description := Delchr(Description,'=','"');
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • themavethemave Member Posts: 1,058
    ara3n wrote:
    another solution is to just add code to remove " when they enter it.

    The following code onvalidate
    Description := Delchr(Description,'=','"');
    
    I use a variation of this method, it works fine, before I export data, I run a processing only report on the table, it removes the charactures. I'm an end user and can't add code to the form, but you can accomplish the same end result with a processing only report.

    I also wanted our customer search name field to not contain any spaces or other special charactures, it should only be letters,
    so John's Truck & Equipment Co. should have a search name of
    JOHHSTRUCKEQUIPMENTCO

    I use a processing only report, that runs from the job queue with the following info.
    using the nested delchr, deletes everything that is not a letter.

    "Search Name" := DELCHR(Name,'=',DELCHR(Name,'=','ABCDEFGHIJKLMNOPQRSTUVWXYZ'));
    Modify;
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Why not just set the CharAllowed property, no code, simple and does what you want.

    Just
    go to the Table designer,
    go to the Description field
    Open properties
    Find the CharAllowed Property
    In this property, enter the secret code #+ !-~
    #+ !-~
    

    That should work for you.

    (copy paste the code so you get it right.
    David Singleton
  • matttraxmatttrax Member Posts: 2,309
    Why not just set the CharAllowed property, no code, simple and does what you want.

    I didn't even know that property existed.

    This is one of those threads I love. Every post is a valid solution to the question.
  • cwigintoncwiginton Member Posts: 16
    David,

    The CharAllowed #+ !-~ worked!!

    Thank you very much!! =D>
  • David_SingletonDavid_Singleton Member Posts: 5,479
    cwiginton wrote:
    David,

    The CharAllowed #+ !-~ worked!!

    Thank you very much!! =D>

    I am lazy, and a terrible typist, so I always look for the easiest solution. :D Glad it helped you out.
    David Singleton
  • Alex_ChowAlex_Chow Member Posts: 5,063
    Why not just set the CharAllowed property, no code, simple and does what you want.

    Just
    go to the Table designer,
    go to the Description field
    Open properties
    Find the CharAllowed Property
    In this property, enter the secret code #+ !-~
    #+ !-~
    

    That should work for you.

    (copy paste the code so you get it right.

    Genius!!!
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Alex Chow wrote:
    Why not just set the CharAllowed property, no code, simple and does what you want.

    Just
    go to the Table designer,
    go to the Description field
    Open properties
    Find the CharAllowed Property
    In this property, enter the secret code #+ !-~
    #+ !-~
    

    That should work for you.

    (copy paste the code so you get it right.

    Genius!!!

    :oops: Thanks
    David Singleton
  • southindiansouthindian Member Posts: 247
    there are certain special characters which i need to delete ,that cannot be mentioned in coding like for example

    (Item description = SWR Pipe Type B SL á 3.6Mtr(12ft)á 90mm) . how to make navision system understand this character ( which is bold). kindly guide... i had passed these special charaters in navision like

    corrstr:=DELCHR(getsrt,'<>','àû');

    but still the special characters is not getting deleted. wats is the fault ?
  • ara3nara3n Member Posts: 9,256
    You wrote
    corrstr:=DELCHR(getsrt,'<>','àû');
    


    it should be

    corrstr:=DELCHR(getsrt,'=','àû');
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • David_SingletonDavid_Singleton Member Posts: 5,479
    SWR Pipe Type B SL á 3.6Mtr(12ft)á 90mm) .
    corrstr:=DELCHR(getsrt,'<>','àû');

    Actually I think also the á and à are an issue. :whistle:
    David Singleton
  • southindiansouthindian Member Posts: 247
    yes sir... you are right ... today morning when i came i found that the special character i have entered is wroang and rectified it... now it is working fine...... :thumbsup:
  • David_SingletonDavid_Singleton Member Posts: 5,479
    yes sir... you are right ... today morning when i came i found that the special character i have entered is wroang and rectified it... now it is working fine...... :thumbsup:


    you're welcome.
    David Singleton
  • AndwianAndwian Member Posts: 627
    enter the secret code #+ !-~
    #+ !-~
    

    What is it mean?
    Is it mean that it only allow any character: #+ <spaces> !-~ ?

    Thank you.

    That's such an out-of-the-box approach. Thinking simply, yet brilliant. Great! :thumbsup:
    Regards,
    Andwian
Sign In or Register to comment.