Page 1 of 1

Use of Auto Increment and Protected fields and user login in ID

Posted: November 19th, 2019, 9:39 am
by sergiofurtado
Hello CSPro team,

I would like to refer you to the implications of including in the ID items an Auto Increment and Protected field as well as the user login (alpha and Protected) already validated and retrieved during Menu execution.

Would including these fields ensure that adding cases never have the same ID?

How to ensure that only the user who added a case modifies or deletes that case?

Thank you very much in advance

Re: Use of Auto Increment and Protected fields and user login in ID

Posted: November 20th, 2019, 7:03 am
by Gregory Martin
Without knowing how the logic is generated, it's not possible to guarantee that the IDs are unique. For example, if someone could log in to two difference devices with the same login, then you'd still get duplicates because the auto increment would start at 1 on each device.

If you can guarantee that enumerators will not change devices while conducting fieldwork, you could prevent alternative users from modifying cases using logic. For example, you could store the device ID in the data in a protected field:
PROC DEVICE_ID

preproc

    // prefill in the device ID when we're adding data
   
if DEVICE_ID = "" then
       
DEVICE_ID = getdeviceid();

    // otherwise prevent modification on devices other than the initial one
   
elseif DEVICE_ID <> getdeviceid() then
        errmsg
("You cannot modify this case!");
       
stop(0);

   
endif;
Preventing deletions is harder because you cannot run logic on the Case Listing screen. What you can do is prevent deletions on that screen (Lock=Delete in the PFF) and then have a delete option in your menu program that controls who can delete what cases.

Re: Use of Auto Increment and Protected fields and user login in ID

Posted: November 20th, 2019, 7:17 am
by sergiofurtado
Hi Gregory,

Thanks for the directions!