Building on Eugene's answer. The correct solution is indeed Scopes, but you're using it wrong, I guess.
The code should be more or less like this
lazy val nameAndProjectID = Def.task {
(name.value, projectID.value)
}
lazy val subListTask = subList := {
nameAndProjectID.all(ScopeFilter()).value.foreach { case (name, id) =>
println(s"Subproject ${id}, $name")
}
}