Hidden tasks and WBS code

In my gantt chart I have some tasks that I don’t want to display to a determined user for example, so I have the following piece of code to handle that

gantt.attachEvent("onBeforeTaskDisplay", function(id, task){
  if (some condition){
    return false;
  return true;

Problem is, when using this method, the tasks still does count as an existing task, thus having a WBS code set, resulting on the following issue. When I add a new task, it assumes a WBS code that doesn’t correspond to what the user is viewing, showing a number higher than the last visible task.

Is there a way to overcome this behavior?

Hi Diego,
sorry for the delay. Unfortunately, there is no way to exclude hidden tasks from WBS calculation.
Right now, the only way to exclude tasks from the WBS calculation is not to load them into the Gantt. I.e. before loading data into the Gantt (gantt.parse / gantt.load) exclude tasks that do not need to be displayed from the set.
Unfortunately, we haven’t a ready demo for such use case and I can’t do a quick example since it appears to be non-trivial. I’ve sent a feature request to our dev team and they will consider adding the ability to exclude tasks from WBS calculations.