This snippet might do it if you're not too picky about which is the first child (generally, you'll get the first one created):
$docId = $modx->resource->get('id');
$children = $modx->getChildIds($docId);
if (! empty($children)) {
return $modx->makeUrl($children[0], "", "", "full");
} else {
return 'No Children';
}
If you want the first child defined by menuindex, it would be something like this:
$docId = $modx->resource->get('id');
$url = 'No Children';
$c = $modx->newQuery('modResource');
$c->sortby('menuindex', 'ASC');
$c->select(array('id','parent'));
$c->limit(1);
$c->where(array('parent' => $docId));
$childObj = $modx->getCollection('modResource', $c);
if ($childObj) {
$childId = $childObj->get('id');
$url = $modx->makeUrl($childId, "", "", "full");
}
return $url;