Error Management with Lookup Temporary tables

BeliasBelias Member Posts: 2,998
edited 2010-11-02 in NAV Three Tier
Maybe there's a topic about this but i don't remember where is it...
example: i have a temporary table and i fill it with two or more loops on the real table. (here's a raw code sample)
Tbitem.setrange("no.",'aaa');
Tbitem.findset;
repeat
  tbitemtemp := Tbitem;
  if tbitemtemp.insert then;
until Tbitem.next = 0;
Tbitem.reset;
Tbitem.setrange("description",'*aaa*');
Tbitem.findset;
repeat
  tbitemtemp := Tbitem;
  if tbitemtemp.insert then;
until Tbitem.next = 0;

now, i'm gonna use this table in order to show a lookup in a request page.
moreover, if the user manually writes a value out of the range of this table, i have to give him an error.
My problem is that i still can't find a smart way to give a descriptive error to the user: here's my current version
-onlookup-
if page.runmodal(0,tbitemtemp) = action::lookupok then begin
  CDMyItemCodeVariable := tbitemptemp."no.";
  Myvalidatefunctionforitemcodevariable;
end;

-onvalidate-
//fill the buffer if the temporary table is still uninitialized
Myvalidatefunctionforitemcodevariable;

-Myvalidatefunctionforitemcodevariable-
tbitemtemp.get(CDMyItemCodeVariable);  //this instruction gives the error "item no. xxx does not exist" <--a bit confusing for the user, 
//as the item xxx DOES exist in the real table, but not in the temporary table
//other processing...

Thanks in advance (there's probably some error in the code, i wrote it in 5 minutes, sorry [-o< )
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog

Answers

  • krikikriki Member, Moderator Posts: 9,115
    Something like this?
    IF NOT tbitemtemp.GET(CDMyItemCodeVariable) THEN
      ERROR('Item "%1" is not valid',CDMyItemCodeVariable);
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • BeliasBelias Member Posts: 2,998
    ok, then i guess that a manual written error is the only way to go...
    now, i was using something like what you wrote me, instead of a standard "GET" error: something like:
    "item AAA not valid, use the lookup button, instead."
    the problem is that the user don't know why its item is not correct, unless i manage every single error that can rise from the temporary table...this is expensive in terms of time of development, so i'll go for the "generic error" solution, that is the "if it was hard to program, it has to be hard to understand!" philosophy :whistle:
    thank you!
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • krikikriki Member, Moderator Posts: 9,115
    The GET-error lets the user always think it is a bug. So this must be avoided.
    Better put a generic error-message so the user knows it is a wrong item but the error in itself is not a bug.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.