Code help - counting characters in a field

I am relatively new to development and C/Side and I am wanting to create a report that looks at various phone numbers in a table flags “faulty” data. i.e phone numbers (usually 6 characters) with more or less than 6 characters and mobile numbers with more or less than 11 Characters. I want the report to print the faulty data in my report. Is there a bit of code that “counts”? any help would be much appreciated? Regards

Think you will need to use STRLEN(“phone No.”) this will return you the number of characters in the Field. do not mistake this with MAXSTRLEN - this will give you the Maximum No. of characters allowed. something like If STRLEN(“Phone No.”) <> 6 then Currreport.showoutput(TRUE);

Thanks, this rings a bell now. Is there any websites I can look at as i am finding this coding hard to grasp! Also, which trigger will this code be inputted into? Regard

The best place to put the code would be in OnAfterGetRecord Trigger of the report you are running. You would then need to use something like - If STRLEN(“Phone No.”) <> 6 then Currreport.skip; I’m not too sure on what websites to visit, this one seems to be the best for any questions you have! Reading the rather large application designer guide supplied with the CD may be an option, or like most of us, just plenty of practice! Sorry

This some code that I have in a String Function Code Unit. Although you currently are only seeking faulty phone numbers, soon you’ll want to format them. See the code below. You can create your own codeunit and make this a function. Then, anywhere in Navision where there is a phone number you can make a single call (1 line of code) to format the phone number. ValidatePhones(OldPhoneNbr : Text[30]) NewPhoneNbr : Text[30] NewPhoneNbr := CleanString(OldPhoneNbr,’()-/# ext.+EXT’); IF NewPhoneNbr = ‘’ THEN EXIT(’’); PhoneLength := STRLEN(NewPhoneNbr); IF (PhoneLength <> 7) AND (PhoneLength < 10) THEN ERROR(’%1 is an invalid phone number. Please re-enter.’,OldPhoneNbr) ELSE BEGIN CompanyInfo.GET; CompanyAreaCode := COPYSTR(CleanString(CompanyInfo.“Phone No.”,’()-/# ext.+EXT’),1,3); IF PhoneLength = 7 THEN NewPhoneNbr := CompanyAreaCode + OldPhoneNbr; TempAreaCode := ‘(’ + COPYSTR(NewPhoneNbr, 1, 3) + ') '; NewPhoneNbr := TempAreaCode + COPYSTR(NewPhoneNbr,4,3) + ‘-’ + COPYSTR(NewPhoneNbr,7,4); IF PhoneLength > 10 THEN NewPhoneNbr := NewPhoneNbr + ’ ext. ’ + COPYSTR(NewPhoneNbr,11,20); EXIT(NewPhoneNbr); END; Globals: Name DataType Subtype Length TempAreaCode Text 6 PhoneLength Integer CompanyInfo Record Company Information CompanyAreaCode Text 3 Return Value: NewPhoneNbr Text 30 Parameter: Name DataType Subtype Length OldPhoneNbr Text 30