Sc_Block_Display vs. Unique Key Validation – Block Appears Incorrectly; How Do I Suppress It Again?

Hi everyone, how are you? I’m creating a form with a unique key field.
I need to hide a specific block only during the insertion mode.
To do this, I check the {campo_id} (which is an auto-increment field) in the “onLoad” event, as shown in the code below:

if ({campo_id} > 0) // update
{
sc_block_display( blc1, on);
}
else // insertion
{
sc_block_display( blc1, off);
}

After pressing the “insert” button, the unique key validation takes place. If an error occurs, {campo_id} receives the auto-increment value; consequently, when the “onLoad” event runs again, the application displays the block because {campo_id} is greater than zero.

Since a unique key violation error occurred, the record was not actually inserted, so {campo_id} shouldn’t have a value.

Could someone please give me a tip on how to solve this?