I don't believe you properly researched this error before asking your question (see here), but to fix it you need to initialise $lists[$i]
to an object before assigning to its properties - change
foreach ($rows as $row) {
$lists[$i]->link = JRoute::_(WorkforceHelperRoute::getEmployeeRoute($row->id, $row->departmentid));
to
foreach ($rows as $row) {
$lists[$i] = new stdClass(); // initialise $lists[$i] to a new object
$lists[$i]->link = JRoute::_(WorkforceHelperRoute::getEmployeeRoute($row->id, $row->departmentid));
PHP allows you to create properties on the fly like this, but only if the variable ($lists[$i]
in this case) is already an object.