You have an error typo that's why the output is always undefined, change your function valueBeforeEdit = event.oldvalue to oldValue.
From this:
const valueBeforeEdit = event.oldvalue;
To this:
const valueBeforeEdit = event.oldValue;
You can read more about simple triggers and installable triggers on this link - Event Objects.