I have a script that:
- reads the contents of a Rich Text field
- creates some new entities (could take some time…)
- puts links to the new entities into the Rich Text content
- updates the Rich Text field
If a user is editing the same Rich Text content while this script runs, some of the user’s edits could be overwritten by the final step of the script.
A simple way to prevent this data loss would be if a script/automation could temporarily lock a specific Rich Text from user edits while it is running, to prevent users from making any changes that would get overwritten by the script’s actions.
The rich text fields are deliberately intended to support simultaneous editing by multiple users. This means that it is always possible that someone else could interfere with/delete/overwrite text at the same time as another user.
Since the automation ‘ghost’ is no more/less capable than a human user, it too can mess things up, if it is making edits at the same time as someone else.
We don’t have any plans to introduce temporary ‘locks’ on rich text (for humans or automations to apply) so I’m not sure there is any way to guarantee that this issue can never occur.
Have you considered using the ‘Append …’ action in the automation, instead of a complete overwrite by the automation?
(even then, it could end up looking weird if it occurs at the same time as another user is composing text at the bottom of the field, but at least the user’s edits should not be lost)
That would not work for this case.
I will have to roll my own version of locking if I want to solve this - I can make the script delete the entire Rich Text and replace it with a warning/explanation at the start of its processing.