This this logic should work I think: ``` function ...
# suitescript
f
This this logic should work I think:
Copy code
function getPercentageCompleted(taskToCheck, pending = 0, total = 0) {
            let percentage = 0;
            try {
                percentage = taskToCheck.getPercentageCompleted();
            } catch(e) {
            }
            if (percentage === 0) {
                if (total === 0) {
                    return 0;
                }
                if (pending === 0) {
                    return 100;
                }
                return 100 * (total - pending) / total;
            }
        }