Page 1 of 1

Find duplicate cases in input dictionary

Posted: May 24th, 2023, 8:14 am
by BK Singh
Gregory Martin wrote: May 4th, 2017, 7:51 am If using 7.0 (which you have to for keylist), you can also use the find function on the input dictionary. Construct the potential key as a string, and then do something like this:
if find(INPUT_DICT,=,keyString) then
    errmsg("You've already entered a case with these IDs");
endif;
I am using an External dictionary to fill my ID items and have protected 3 out of 4 ID items, 1 is unprotected for loadcase to fill rest of the dictionary item. If we enter in unprotected field (which is unique) function should check if this number used before or not. If the number is already used then an errmg should appear. Please explain the process to use the find function or any function which can create condition for reflection of error message before system generated msg appears.

Re: Find duplicate cases in input dictionary

Posted: May 25th, 2023, 11:10 am
by Gregory Martin
You are going to get that system message as soon as you enter the ID field, so what you can do is add an item to your dictionary (to a record, not the IDs), and then have the user enter the ID value to that field. You can then assign it automatically to the ID field. Something like this:
PROC ENTERED_HH

    if find(DICT_NAME, =, maketext("%v%v%v", PROVINCE, DISTICT, ENTERED_HH)) then
        errmsg
("You cannot enter another household %v.", ENTERED_HH);
        reenter;
    endif;
   
    // assign the entered household number to the real ID;
    // HH will be on the form, protected, after ENTERED_HH
   
HH = ENTERED_HH;

Re: Find duplicate cases in input dictionary

Posted: May 27th, 2023, 10:45 am
by BK Singh
Thank you sir. It worked