[MongoDB] MongoDB Integration To OutSystems
Web icon
Forge component by Barduino

Hi! I'm having a difficulty integrating my MongoDB database using the MongoDB plugin from Forge. I'm doing the same approach as shown in the MongoDB Demo (i.e. creating a different module for the backend and putting the logic in wrappers) but I was not able to get any results from my query. I also created a structure for the data that is expected to be returned by the database. Maybe I'm missing something somewhere in my module. The option of using REST services is not applicable since I was required to use "pure" OutSystems only.

Can someone please help me with this? Thank you!


Hi Bryan,

A simple MongoDB query will look like this, in Service Studio:

On the MongoDocumentQuery action, you'll have to pass the following parameters:

  • ConnectionString
  • DatabaseName
  • CollectionName
  • FilterJSON

Here's an example:

Afterwards, you'll have to iterate over the query results, deserialize each document into a structure and append it to the resulting list.

In which part of the process are you having problems?



I have a Movie App in which I am trying to retrieve a single item. I supplied the required parameters as shown on the pics below. Yet whenever I am executing the MongoDocumentGet action, I am not getting any result.

This is my query: 

This is the result when I ran the debugger:

I'm wondering if there is something wrong with the parameters I supplied, or if building a "core module", just like in the MongoDB Demo and implementing it in my project is a wrong idea. I have checked the connection string, database and collection names and I'm sure that they are correct.


Hi again,

The action MongoDocumentGet will try to fetch a Mongo document by its internal identifier (_id).

A equivalent query on Mongo would be:

  db.collection.find( { _id: "your-identifier" });

From what I see, it seems the MovieId you're providing doesn't match with any _id in MongoDB.



Sorry for the late reply.

I did a query on MongoDB Compass, and the item exists on the database.

As you can see, it is the same identifier that I used on my query below.

Maybe there is something here that I have missed. I'm still figuring it out though.


Hi Bryan,

Yep it seems correct. Here are a couple of extra things you can check:

  • Are the database and collection names correct?
  • Have you tried querying all documents and check the result?

Hi David!

I tried querying all the documents and it did return my desired result. But whenever I try to query using the MongoDocumentGet, it doesn't return anything. I think I'm almost there. I'm still tweaking around the FilterJSON parameter of MongoDocumentQuery, as well as the id parameter of MongoDocumentGet. 

I will update here ASAP. Cheers!


I tried the action MongoDocumentQuery and supplied the FilterJSON parameter, this is the result:

It's empty.

It's the same thing with MongoDocumentGet.

I'm starting to think that the culprit is the argument or the value of the id being passed in the id parameter of those actions.

And also, I'm wondering if the version of OutSystems that I am using has something to do with this problem. I am using OutSystems 11.


Hi Bryan,

What are you passing on the "id" parameter?

Have you tried using MongoDocumentQuery and filtering by other fields?



For what it is worth after 5 months..

Your document is stored with the id being wrapped in ObjectId(id). This is done in the .NET code by the Document_Insert. Also see this page as reference.

The MongoDocumentGet is executing a Find method with the {_id:<your document id>} as query. With just providing the id as


the Find method is not finding your document, since it is stored in the form


looking at your provided screenshot.

I think you need to enclose your Id with Object() in order to have it retrieved.

Hi Bryan,

Have you been able to resolve the issue? I am having the same problem. Please let me know.

Hi Yulia,

Have you tried the new integration manager tool? I read there they have Mongo support now (well technical preview)


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.