Is there a way to detect when the wbscode changes?

Well, when you change a child activity or drag an activity updatetask updates the selected activity but the affected activities in its wbs do not update them

Hello Dan,
There is no built-in way to do that. You will need to implement a custom solution by using the Gantt API and Javascript.
When you reorder, create, or delete a task, the WBS code of the tasks below should change. But the WBS code of the tasks is something that is calculated, it is not a standard property.
You can save the WBS codes in an array or a task property and check if it is changed after you did something.
Here is an example of how it might be implemented: