Hey. I need to make a workflow that essentially alerts if another user is actively on the same page, to prevent duplicate database item edits from the page. I would prefer to not use a plugin, but I’m having a hard time with configuring a functional workflow with JavaScript. And I would assume there are no other options.
You can try to think of it like this.
This item that cannot be duplicated.
It can have fields like:
current_editor: User
in_editing: Yes or no
When another user enters this page, you can fetch the item and then see that it is being edited by another user.
What you will need to create as a rule besides this is how the user who is “editing” the item will be disregarded afterward. Is it when they close the page? When they leave edit mode.
But does this idea, that the item has the current editor and whether it is in editing, make sense?
I have such an implementation in place already, the issue I have is how do I trigger the reset of that boolean value. Essentially I have a database entry that is made for a given item and its values are the item being edited, whether it is being edited or not and who is the user doing the edits. The triggering of that workflow is simple, embedding it within the ‘Page is loaded’ workflow does the job, but the reverse is not as simple. If the page is closed, the editing boolean should turn to “no”.
What’s the exact use case in the app that requires this functionality? I understand to not have two users edit same data at same time, but why? What type of app is it and what kind of data needs no edits at same time?
You can trigger a ‘Page is Closed’ workflow by setting up an event listener or status change that detects when the page is closed. Ensure your workflow is configured to execute automatically upon that trigger.
Essentially, the page I’d need it for is for making edits to prices of items in stock. It’s both confusing and wastes time if the same item is edited concurrently by two people.
Where should I place the event trigger and what workflow do I use to execute the listener? Is it on the page that handles the pricing, or the main page to which the user returns to after closing the window?
Also if you’re referring to the status change as using custom states, don’t they work only within an individual page? E.g. opening a page can trigger a custom state change but closing a page (except if you do it via a specific button, not just closing it via the browser for example) can’t do that, as far as I’m concerned. Sorry if I misunderstood.
The speed at which changes in DB are reflected on a page with real time data is pretty fast. I wouldn’t imagine a single company with multiple employees all having same task set on single day to update prices of same products would run into problems.
Unless, is the use case more complex than a single company making changes to prices of products? If not, and you’re still concerned, consider having CSV upload as way to make the edits for all products at same time by single upload of single CSV.
What industry is the app for?