2

Overview - I'm trying to sync some data to google firestore using Integromat. However I cannot seem to find the correct way to save an array as the output for a particular field. It seems like this should be easy but everything I've tried has failed so far.

Example, using the simplest form of this I have an input string like so

Input JSON: { "Brand": "Ford", "widgets": [0,1,2] }

And I basically just want to save that in the same structure into firebase, but I can't seem to configure the 'Update Firestore Document' module correctly. The closest I can do is to save it as a string, so it looks like this in firebase:

Output Firestore: { "Brand": "Ford", "widgets": "0,1,2" }

Below I'm attaching images of the integromat setup, showing how I'm trying to hookup the output values into the firestore module. When I try and pass the array directly I get the error message. "Array of objects expected in the parameter 'Value'"

00 - Basic 2 node setup in integromat

01 - input json in integromat

02 - output from input module

03 - saved ok as string

04 - set to store as array won't work

05 - error message

10 - desired output example

11 - actual output so far, save as string in firestore

Dharmaraj
  • 47,845
  • 8
  • 52
  • 84
  • Can you share the RAW feed text instead of the image? – Runcorn Aug 31 '21 at 12:05
  • Hi, thanks for having a peek, it's in the original question as the input json... namely { "Brand": "Ford", "widgets": [0,1,2] } and once integromat read it, the first output bundle is the same just as an array that it can iterate over. [ { "Brand": "Ford", "widgets": [0,1,2] } ] – Richard Soluis Aug 31 '21 at 14:37
  • Sorry, I commented on the wrong post accediently. I will review your problem and see if I can help you on this. – Runcorn Aug 31 '21 at 21:43

1 Answers1

1

I have reviewed your integration and one thing that needs to be fixed is the way you are passing the Array of Values in Google Cloud FireStore through Integromat. When reviewing the API the expected format for FireStore looks something like this,

{
    "fields": {
        "widgets": {
            "arrayValue": {
                "values": [
                    {
                        "integerValue": 0
                    },
                    {
                        "integerValue": 1
                    },
                    {
                        "integerValue": 2
                    }
                ]
            }
        },
        "brand": {
            "stringValue": "Ford"
        }
    }
}

But, Since the app is developed in Integromat there are few changes while you are using Map instead of setting each item in Firestore Array. After reviewing it, Integromat expects objects with the following fields as arrays that you need to create and pass instead of using widgets[] as you have done in the current implementation.

[
  value : 0,
  valueType : "integerValue"
]

To achieve this, I have created the following Scenario(Not Sure how operation effective is it, but I get it working), enter image description here

Data Structure Used is following which you can use through the generator and is used for Aggregator and Parse JSON module,

[{
    "value": 0,
    "valueType": "integerValue"
}, {
    "value": 1,
    "valueType": "integerValue"
}, {
    "value": 2,
    "valueType": "integerValue"
}]

Array Aggregator in second last step will then aggregate value and valueType and will be used in Google FireStore as,

enter image description here

Runcorn
  • 5,144
  • 5
  • 34
  • 52
  • Thanks so much for digging into this and finding a solution. Awesome! Just attempting to recreate it in my test scenario now. (I upvoted your post but don't have the ranking to affect it yet). – Richard Soluis Sep 01 '21 at 21:26
  • No, Problem, If this works for you, you can mark this as an answer, let me know if you need further help on this. – Runcorn Sep 02 '21 at 11:14