Assigning messages with category from another database


Hi, I have two Mongo collections, Chatrooms and Messages. Both uses autoform to insert documents to the database.

When entering a chat room in route chatroom/_, the user can insert a Message. What is the reccomended way to assign the Chatroom ID to the Messages?

Can I create a variable that stores the current Chatroom ID and use this variable to populate a field in a new Message Autoform?