Im programing with navision classic for about 2 months and i came across an error in my codeunit, i have one table with some values and the other the problem is that my second table has an onvalidate trigger and lets say when im trying to secondtablerecord.VALIDATE(second_table_field,first_table_field); i get an error that says that the value doesnt exist in the second table i somehow need to intercept the error and lets say make waserror:=TRUE variable is it possible and how is it done in a single codeunit? and my codeunit funcion is in a cycle NEXT so i need it not to break it on error can you help me?
WasError:=False;
SRec.INIT;
SRec.“No.”:=’’; //THIS IS NEEDED SO THAT IT CAN GENERATE A NEW NUMBER SEQUENCE
SRec.INSERT(TRUE); // TRUE Because oninsert triger has a new number generation sequence code
SRec.VALIDATE(FRec.field_name,SRec.field_name); // I GET AN ERROR HERE
What i need is to intercept that error lets say like an IF statement if it is successful than do nothing but if it fails and gives me ant erro set the WasError:=True;
the data types match of both fields length matches , the Frec.field_name is a normal field which has a table relation to another table where all the possible values it can get are stored but when i try to insert a value that doesn’t exist in there i get the error: third_table_name CODE value_that_i_try_to_insert does not exist editing the table on validate code is not an option so i need a simple way to intercept the error. Thank you in advance .
i could use this but it will find the records because in Frec table they are all there, so that doesn’t help me
Mohana ,
i wrote the validate syntax exactly as you said your solutions helps me but as i have about 30 validation syntaxes i have to write the get syntaxes to all of them in case of an error isint there some other way ? if there isint this i think will suffice
I think you need to define parameter for Second record for it will be not generate any data or empty. try to use SETRANGE before Looping with First Record and define its relation i think this should work, if both record avaiable
the main idea is to getlasterrortext o that means i have to go through all the code and if i get an erro insert it to a LOG lets say i have a name test and a table where the names are stored the third table Names which has 3 entrys test1,test2,test3 so if i use validate the NAV will give me a error because name test doesnt exist in the NAMES table that means i have to somehow not to stop the process and at the end of the code insert the getlasterrortext string to a log.
Okay I think i get your point, perhaps try to put some checking in Looping before INIT and generate an error message within the checking statement, like your conditions “doesnt exist in the NAMES”
IF FRec.FINDSET THEN
REPEAT
//here you need one function to pass a record and a triger value lets say SetTriger(‘runit’,Srec);
boolvar:=CODEUNITVariable.RUN;
IF boolvar THEN
BEGIN
//write if everythings is fine
end ELSE
BEGIN
//do something if its bad
END;
UNTIL Frec.Next=0;
but still thanks for trying to help me maybe this sollutionds will be helpfull to someone