You're creating a new object with the data from the resource object in the database. That's not the object being parsed for the page.
It might (or might not) work to use this:
$modx->resource->set('longtitle', something);
If it makes sense to do what you're doing in a plugin. You can create one attached to OnParseDocument, and just use str_replace to replace the tags before they're parsed. That would be the most efficient.
If that doesn't work and you want a dynamic longtitle, I'd just replace the longtitle field tag with a snippet tag and have the snippet return whatever you want to go there.
Another option would be to use a built-in or custom output modifier to use in the longtitle tag.