API Example: Change the function to compute what resource is overloaded

Modified on Thu, 5 Mar, 2020 at 11:34 PM

This functionality is available since version 2.3.0!


By default, the resource is marked as overloaded, if it has more items assigned than a limit. 


Imagine you want to mark the resource as overloaded only if the resource has more UNRESOLVED (i.e. open) items assigned than a limit.


Example: you want to achieve the situation as on the following screenshot: Steve Developer is overloaded on Dec-18  but not on Dec-19 because on that date all tasks are resolved, except one task (the only unresolved is EL-136).


To configure this, add the following script to Widget Properties > Advanced > Gantt Script


gantt.templates.checkOverloadedResource_function = function(start_date, end_date, resource, tasks){
    var unresolved_tasks =  tasks.filter(task => !task.resolved);    
    if(unresolved_tasks.length > 1){
        return true;
    }else{
        return false;
    }
};


Of course, you can write more complex scripts, e.g. taking into account partial assignments such as if the task does not load the resource to 100%.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article