How to update field with conditional logic