add the trigger on tablename_add → then run the func to check the idx value and logic for the field changes.