Hi everyone
I'm new into NAV so maybe my question will seem a bit noob but here it goes.
I created a table which has a field called ID number where user needs to enter a 10-digit integer which represents his/her's ID.
I must create a function that will check if this number is correct by checking if it satisfies following criteria:
If number is ABCDEFGHIJ, then digit J (which is called control digit) must be equal to:
J=13-( 7*(A+G) + 6*(B+H) + 5*(C+I) + 4*(D+J)) MOD 13
and also, needs to satisfy criteria below:
J <= 9 -> X = J
J > 9 -> X = 0
I thought using function FORMAT first to convert integer to string and then COPYSTR for each of local variables A,B,C,D... but it doesn't work
Can anyone please help me out with correct code?
THANK YOU IN ADVANCE!!!
Answers
Pardon to ask but the question is yet not clear to me - You said you have created a Table with Field ID where users are supposed to enter an Integer value with 10 digit.
Now what you have selected the data type for this integer value? If it's integer then integer ranges from -2,147,483,647 to 2,147,483,647. So what if user is entering an Integer value of 10 digit greater then 2,147,483,647.
Now you wrote If number is ABCDEFGHIJ,, If it's an integer value how it could be ASBDEFGHIJ??
Let me know if I misunderstood something.
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/
Can this code be written for my custom function?
What code you want you to write in your custom Function, please elaborate a bit.
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/
If my code is ABCDEFGHIJ
THANKS!
textVar := format(ID);
IF NOT STRLEN(textVar) = 10 THEN
ERROR('I need 10 digits, buddy');
EVALUATE(intArr[1],textVar[1]);
....
....
EVALUATE(intArr[10],textVar[10]);
intHelper = 13-(7*(intArr[1] + intArr[6] .......... ; //your formula
if inthelper <> intArr[10] then
error('checksum wrong!')
Of course assuming your ABCDEFGHIJ are actual numbers and you just used the letters to point out your problem.