Is there any way to detect if someone is currently...
# suitescript
d
Is there any way to detect if someone is currently editing a specific transaction? I can pull the event type with a client script, but I don't know if the user has closed the page without saving/cancelling Use-case is warning when invoicing Sales Order while Sales Order is currently being edited by someone
b
a complicated solution could be to use a custom record as a lock
make a custom record for every transaction, check a checkbox on the custom record during beforeLoad to indicate that someone is editing the record
create the warning if someone else edits the transaction while the custom record has the checkbox checked
uncheck the checkbox on save
you will want to implement an activity check on an interval so can detect when someone edits a transaction and doesnt save
probably via a timestamp on the custom record that you can also check to determine if you should show the message
depending on how long the interval is and how long you take to consider an edit attempt abandoned, you may be able to edit the timestamp in client script, or at worst an xhr to a suitelet that does the work
d
Thanks battk, lots to think about I think timeout interval might be the way to go Luckily I can simplify my logic that I'm only concerned with SO's of certain status (pending billing)
I also think I can get away with a single "editing lock" record that just consists of field for the transaction's internal id and a timestamp As target action (in this case invoicing) is only concerned with the transaction's id, not its type Okay, feeling optimistic
b
the multiple custom records is to support multiple editing multiple records at a time
the checkbox is to release the transaction when its saved so it doesnt need to wait for the timout
👍 1
m
i vaguely recall someone here mentioning they built something very similar, maybe @jen?
j
Yes, that was me. I created a “record edit audit (logger)” that tracks when someone opens a record in edit mode. A client script then runs every three minutes updating the “last alive” time. Some browsers (not all) work to mark the record as “inactive” when the person navigates away, but because this doesn’t always work, my tool checks the “last alive” time if there is an “open” “record edit audit” on that record. If the last alive time is > 3 minutes it marks it inactive, otherwise it pops up a warning saying who is currently editing (and when).
I also have a scheduled clean up script that runs every 15 (? I think) minutes to mark inactive any that are idle.
d
Thanks Michoel, Jen, that's brilliant