Hi all, I’ve been exploring the Firebase Realtime Database forge component and attempted to use it for real-time events in my application. However, I’ve noticed that the implementation is different from what I'm familiar with in O11. Can anyone shed some light on configuring the "ref" in the action (subscribe)? Tried below but not successful -- Returning error: Query.on failed: Was called with 1 argument. Expects at least 2. I have entered the web API key, databaseURL and projectId on the block, assuming it was successfully initialized (no error in console/log). And There is another forge -- Firebase Extension which I believe it is used to trigger server action for firebase realtime database (Firebase web version in O11), correct me if I'm wrong. Based on my understanding on the flow, I should use the OnAfterFetch to run GetDataRealtime after the initFirebaseRealtime was loaded (block), then I should use setData to create/update the data into my firebase rtdb, and the GetDataRealtime should be triggered to return me the json from my firebase. Again, those are just my assumption on how it works with this ODC forge.
Appreciate if anyone can share their experience with ODC Firebase Realtimedatabase (Pub/Sub).Regards,
Kenny
To integrate Firebase Realtime Database with your OutSystems application, follow these step-by-step instructions:
Step 1: Set Up Firebase
Create a Firebase Project:
Navigate to the Firebase Console.
Click on "Add project" and follow the prompts to create a new project.
Enable Realtime Database:
In your Firebase project dashboard, select "Build" > "Realtime Database".
Click "Create Database".
Choose a location and set the security rules. For initial testing, you can select "Start in test mode", but remember to update the rules before going to production.(Firebase)
Retrieve Firebase Configuration:
Go to "Project Settings" (gear icon) > "General" tab.
Under "Your apps", select the appropriate platform (e.g., Web) and register your app if you haven't already.
After registration, you'll see your Firebase SDK snippet, which includes:
apiKey
authDomain
databaseURL
projectId
storageBucket
messagingSenderId
appId
Note down the databaseURL and projectId for later use.(OutSystems Success, OutSystems)
Step 2: Install Firebase Realtime Database Component in OutSystems
Access OutSystems Forge:
Open your OutSystems Service Studio.
Go to the OutSystems Forge.(Reddit)
Search and Install Component:
Search for "Firebase Realtime Database (ODC)" component.
Select the component developed by Ifabula Digital Kreasi.
Click "Install" to add it to your environment.(OutSystems)
Add Component to Your Application:
In your application module, go to the "Manage Dependencies" section.
Search for the Firebase component and add the necessary dependencies to your module.(OutSystems)
Step 3: Configure Firebase in OutSystems
Set Site Properties:
In your OutSystems application, navigate to "Data" > "Site Properties".
Create the following site properties:
FirebaseProjectId – Set its default value to your Firebase projectId.
FirebaseDatabaseURL – Set its default value to your Firebase databaseURL.
Initialize Firebase in Your Application:
Use the InitFirebaseRealtime client action provided by the component to initialize Firebase.
Pass the FirebaseProjectId and FirebaseDatabaseURL as parameters.(Reddit, OutSystems, OutSystems)
Step 4: Implement Realtime Data Operations
Set Data in Firebase:
Use the SetData client action to write data to a specific path in your Firebase Realtime Database.
Provide the path and the data you wish to store.(Firebase)
Get Data from Firebase:
Use the GetDataRealtime client action to read data from a specific path.
This action can be used to retrieve data in real-time as it changes.(OutSystems)
Subscribe to Data Changes:
Use the Subscribe client action to listen for changes at a specific path in the database.
Define a callback to handle the data whenever it changes.
Step 5: Test Your Integration
Publish Your Application:
After setting up the Firebase integration, publish your application to make the changes effective.(Reddit)
Test Data Operations:
Run your application and test the data operations (set, get, subscribe) to ensure they work as expected.
Monitor the Firebase Console to see if the data is being written and read correctly.
Note: Ensure that your Firebase Realtime Database security rules are configured appropriately to allow read and write operations from your application.(Firebase)
If you encounter specific issues or need further assistance with any of these steps, feel free to ask!
Appreciate for your time looking into this. May I know how do you setup your "ref" using the existing forge? My understanding on the ref is the specific path but it seems like it is not working on my end. I will try with a different path and try again when I'm free.
Regards,
Sure! Here’s a clear explanation about setting up the ref (reference path) when using the Firebase Realtime Database Forge component in OutSystems:
What is ref in Firebase Realtime Database?
The ref represents the specific path in your Firebase Realtime Database where you want to read or write data.
It works like a pointer to a location in your JSON database tree.
How to correctly set up and use ref with the Forge component:
Understand the Firebase Database Structure Your Firebase Realtime Database data is organized as a JSON tree. For example:
{
"users": {
"user1": {
"name": "Alice",
"age": 25
},
"user2": {
"name": "Bob",
"age": 30
}
To refer to user1's data, your ref should be: /users/user1
Use the Correct Syntax for the ref
Always start your ref with a forward slash /.
Use forward slashes / to separate nodes in the path.
For example, to write to Bob’s name, your ref would be: /users/user2/name
Set ref Value in OutSystems When calling actions like SetData, GetDataRealtime, or Subscribe, pass the ref as a text parameter with the path string.
Example in OutSystems action input: ref = "/users/user1"
Troubleshooting Tips
If data is not being written or read, double-check that your path exists or is writable.
Verify that your Firebase database rules allow access to that path.
Try using a simple path first, like /test to see if basic operations work.
Avoid trailing slashes / at the end (e.g., /users/user1/ can sometimes cause issues).
Summary
Issue Solution
Can you share me your oml? That would be helpful.