How to get code to run in an order

I’m not sure if booleans are set to false by default in the database…they could just be falsy in which case your code would not run as expected. Is your field’s key actually “_scanned” or is it “scanned”? If it’s fetching the wrong field data, it might be throwing back a truthy value. Also have you defined “type” in an upper scope?

Last, make sure you’re declaring what fields to update as per the API: