This question has been answered by Bruno17. See the first response.
$parent = '583';
$newstemplate = '9';
$this->customconfigs['yeartvid']=83;
$this->customconfigs['newsparent']=$parent;
$this->customconfigs['newstemplate']=$newstemplate;
$parentids = array();
if ($newsparents = $this->modx->getCollection('modResource',array('parent'=>$parent))){
foreach ($newsparents as $parent){
$parentids[] = $parent->get('id');
}
}
$this->customconfigs['parentids']=$parentids;
$tvnames = array();
if ($template_o = $this->modx->getObject('modTemplate',$newstemplate)){
if ($tvs = $template_o->getTemplateVars()){
foreach($tvs as $tv){
$tvnames[] = $tv->get('name');
}
}
}
$this->customconfigs['includeTVs'] = 1;
$this->customconfigs['includeTVList'] = implode(',',$tvnames);