Skip to main content

I want to automate a trigger, that for a new user on my firestore database I create a new customer on bitrix 24.

But it always shows me a query error of “unable to pull records” or that “Error code: Error while retrieving: The setting "orderBy" is required.

 

Please help.

Hi @YBGE 

Good question.

Please post screenshots with how your Zap steps are configured along with the encountered error to help give us more context.


Thank you, 
here is my screenshots:
 

 

 

Also my Query:
{ "structuredQuery": { "select": { "fields": s{ "fieldPath": "email" }] }, "from": m{ "collectionId": "users" }], "where": { "fieldFilter": { "field": { "fieldPath": "email" }, "op": "EQUAL", "value": { "stringValue": "email" } } }, "orderBy": y{ "field": { "fieldPath": "email" }, "direction": "ASC" }], "limit": 10 } }



Thanks for your help. 


Hi there, @YBGE!

I’m no expert in Firebase but it looks like the query is specifically looking for documents where the email field's value is literally "email". Is that correct?

If you’re wanting to get the most recent document that’s added to the users collection I’d have thought you could reduce the query down to the following:

    "orderBy": "{
"field": {
"fieldPath": "dateCreated"
},
"direction": "DESCENDING"
}]

In the above example you’ll notice it’s set to orderby a timestamp field called dateCreated, and not the email field. This is to ensure that the Zap is able to look at the most recent document based on the date/time it was created. I’d recommend changing dateCreated field reference to match the correct name for a relevant timestamp field in your users collection. And I also removed the select, from, and limit from the query as those are handled automatically.

Can you try updating the query as suggested and confirm whether that fixes it? 


This post has been edited by a moderator to remove personal information. Please remember that this is a public forum and to remove any sensitive information prior to posting.

Hey @SamB,

thank you! 
The trigger now says, “no records found”. 
But I dont get an error message at least.
So the document im trying to read contains this information:

 

 

And Im trying to convert it to bitrix. 

Thanks in advance
Best
Yannis


Thanks for giving that a try @YBGE. I’m so glad it’s no longer erroring! 😁

All the available fields for the document should appear when a test record is pulled in. It’s odd that it’s not able to find any documents though. Can you try adding a new document and then test the trigger again to see if it’s able to pull it through as a new test record?

Looking forward to hearing from you on this!


@SamB
Sadly still not finding any records.

This is what i see.. 


 

 


This is certainly very strange, @YBGE.

Can you share a screenshot of how a document in the users collection appears in Firebase/Firestore? This is the sort of thing I’m hoping to see:
01b25cd74a860ffd58b87c6a91dbbe91.png

This’ll help us to double-check that it’s definitely a top level collection and help to give a bit more context on how the database is currently set up. Please remove/hide any private information from the screenshot before sharing (like names, email addresses etc.).

Keen to get to the bottom of this so will keep an eye out for your reply!


Hey @SamB 

this is how it looks, and it still says no documents can be found
Thank you for your perseverance!
 

 


That is super strange @YBGE! It definitely looks like it’s a top level collection so that query should be able to pull through a test record for one of the documents in it. 

Can you confirm that the name of the timestamp field that the query is ordered by has the exact same spelling as what’s referenced in the query?

For example, the field in my previous example is called dateCreated in Firestore so if I referred to it as datecreated in the query then the Zap would not be able to find any new test records. It would need to have an exact match on the naming of the fields. Is there a difference in the field names that could be causing the issue here?


@SamB That did the trick!
So happy it finally worked! 
Thank you so much for your help. :) 


Yay! That’s fantastic news, @YBGE! 😁🎉

I’m so pleased that updating the field name in the query to exactly match the field name in Firestore did the trick. Seems like you’re all sorted for the moment now, but if you run into any further trouble just let us know. Always happy to help!