PREVALIDATING ORDER NO's

MatStephensSandAMatStephensSandA Member Posts: 74
Hi all HAPPY NEW YEAR AND ALL THAT JAZZ!!!!

Now down to the issue lol...

My users are increasingly using special characters in the item number ie P456/2(1).

Having told them time and again that this casues issues when filtering i have given up on human common sense. ](*,) I want to prevent this from occuring again by implementing better text string control

I can see two ways of doing this :
1) Via the properts of the Filed using CharAllowed and ValuesAllowed. I can specify exactly which characters however this meant typing the alphabet in both case setting and all numbers including valid special characters such as full stops and unsersore etc.

2) using STRPOS to search the string for each special character one read at a time

As far as i can tell both are extreemly time consuming the 1st to set up and the 2nd will increase the number of reads of the record before accepting it therefore slowing the validation of the field

Is there a way to search the string for a predefined set of characters and reject the field accordingly???

Thanks in advance
M@
I have seen the future and it's egg shaped.

Answers

  • jannestigjannestig Member Posts: 1,000
    HOw about going around to their keyboards and removing all the buttons with special characters :mrgreen:
  • ssinglassingla Member Posts: 2,973
    You can use the number series which will assign automatic numbers.
    CA Sandeep Singla
    http://ssdynamics.co.in
  • MatStephensSandAMatStephensSandA Member Posts: 74
    jannestig wrote:
    HOw about going around to their keyboards and removing all the buttons with special characters :mrgreen:

    if i had my way it would happen lol...
    M@
    I have seen the future and it's egg shaped.
  • MatStephensSandAMatStephensSandA Member Posts: 74
    ssingla wrote:
    You can use the number series which will assign automatic numbers.

    Unfortunately our system is over 6 years old and the salespeople are now reliant upon naming our Item numbers the same as the customers part number. To change this now would mean re-educating the entire salesforce.

    I have used the Number Series codeunit by adding a function that checks for each special character one at time but i thought i was being a little bt unimaginative. My code does work i just wondered if there was a better way. My code currently looks like so..

    ONVALIDATE
    NoSeriesMgt.PreventSpecialCharacters("No.");

    i := STRPOS(ItemNo,'@');
    IF i <> 0 THEN
    ERROR(''You cna not insert %1 in this field!','@');

    this is then repeated for each special character.

    I just thought this was a little basic and there had to be a better way.
    M@
    I have seen the future and it's egg shaped.
  • krikikriki Member, Moderator Posts: 9,110
    Try this:
    txtAllowedChars := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; // string with all allowed characters
    
    IcodItemNo := DELSTR(IcodItemNo,'=',txtAllowedChars);
    IF IcodItemNo <> '' THEN
      ERROR('Characters "%1" are not allowed',IcodItemNo);
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • MatStephensSandAMatStephensSandA Member Posts: 74
    thanks Kriki.. I knew ther was a better way im just too dumb to see it.
    Thank you all.
    This can be marked as solved.
    M@
    I have seen the future and it's egg shaped.
  • kinekine Member Posts: 12,562
    This can be marked as solved.

    This is on you - just change the subject of your first post... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.