Is there a way to lock cloud records from updating

I need a way to lock particular cloud records in a model from being updated by users if they make an offline edit and then come online. I am ok with discarding/refusing those edits.

If they are online, we are using a boolean flag with logic in the view to block edit, but if they went offline before the flag was set, someone could make edits and I need to discard those edits.

Is there a way to do this?

Yes, you essentially have two options (broadly speaking)

First option, force the user to be online at the time when they want to save changes, and then do an online check to see if the lock flag is set before saving. (Note you need to do the save before calling .dismiss() as dismiss will also persist changes to view variables.

Second option (used if you need to allow users to make changes offline and decide whether or not those changes should get persisted once they get back online), make the changes to a clone of the original object, save the clone and then have online (Cloudcode or Manual) business logic that determines whether or not the changes on the clone object should be applied/persisted to the original object. Using this method you can essentially implement any custom conflict resolution strategy