You need a hidden view named (UNID) which has one column with a formula of:
@Text(@DocumentUniqueID)
Run this as a nightly agent:
SELECT @IsAvailable($Ref) & @IsError(@DbLookup("" : "NOCACHE"; "";"(UNID)"; @Text($REF); 1)); @DeleteDocument