Validating arrays using Firestore rules - google-cloud-firestore

In my HTML page I have a group of five checkboxes. Their values are 1,2,3,4,5.
In the object to which those checkboxes belong I save them as an array. So if user selects options 2,4,5 I store it as [2,4,5].
I'm stuck at the spot when I try to validate that array in Firebase rules. Is there any way of doing validation like this?
I want to make sure an array like [5,6,7] does not go through the Firestore rules but something like [1,3,4,5] does.

Array type fields in Firestore documents show up as List type objects in security rules. You can use its hasOnly method to determine if the List contains only certain elements.
request.resource.data.arrayField.hasOnly([1,2,3,4,5)

Related

Firestore - saving external links in a document with both url and title

How can I create an array in firestore that can save external links?
I want to save the title and the href so that I can use both values in the read.
I want the links attribute to be an array so that I can save multiple links. Is it possible to do that in a single firebase attribute, or should I create separate link attributes with a href and title for each one (ie firstLinkTitle, firstLinkHref)?
It's not possible to have a number of links, that would be a different array - similar to an array of arrays.
The possibility for the creation of a field of type array for your documents, you can either use the console, where this type is available or via code as the following example:
const data = {
stringExample: 'Example',
arrayExample: ['Title', 'href']
};
const res = await db.collection('data').doc('one').set(data);
With the above example, you should be able to create a field of type array and set the data to it.
Besides that, if you want to update data from your array without uploading all the data again, you can use the function arrayUnion() or use the arrayRemove(), to remove elements from it.
You can get more information on how to work with arrays in Firestore, by checking the below documentation.
Add Data
In case you need something like nested arrays, indeed, you will need to have a "child" collection that will be linked to the father one.
Let me know if the information helped you!

Filtering a datasource using multi select wild character

Does anyone know if there is a wildcard character in AppMaker that can be used for all possible values for a field in a query?
I currently have a datasource that is being filtered based on the status using a multi-select widget. What I would like to accomplish is when all values have been de-selected I want to load all the records of that datasource without clearing the entire query in case other filters have been applied. I have it working in-a-sense that I have to explicitly construct my query as such:
widget.datasource.query.filters.Status._in = ['Status Value 1','Status Value 2','Status Value 3']
My current solution is loading the correct data when a value is selected and it correctly shows the union of the query as the values are modified. However, it selects all of the values in my multi-select; which I know is how it is supposed to work.
I tried using widget.datasource.query.filters.Status._contains = ''; and changing the assignment value to no avail. I even tried the opposite approach using _notContains
The intended outcome is to have a filtering dashboard appear much like any website where when no filtering is selected all records are displayed. I was hoping to find a wildcard character that would load all of the records. Just trying to find a way to mimic other website filters with all records when none are selected.
Thanks for the time!
So the easiest solution here is to set up your Multiselect as follows:
Options binding:
#models.YourModel.fields.Status.possibleValues
or if you don't have the possible Status values in your model then set your options binding to:
['Status Value 1','Status Value 2','Status Value 3']
Values binding:
#datasource.query.filters.Status._in
Now anytime you select any choices in the multiselect, the query will only include records that include the selected choices. And if you deselect all choices the query will ignore that filter or treat it as an empty array of values, therefore returning all records unless you applied other filters.

Get more product field value in Algolia json data

We are using Algolia extension for Magento 2. We added 2-3 field in the products, so we want to show the value of those fields on instant search result page. As we checking the view/frontend/templates/instant/hit.phtml is in use, we want to add the custom attributes to the JSON data so we can fetch those attributes value and show in listing page.
First you have to add new fields to Algolia product index if not already added. You can use one of the custom backend events. e.g. algolia_after_create_product_object
Once your fields are indexed properly (verify from Algolia account console), you should be able to get those in hit.phtml

Repeatable Form elements

I need to allow the users repeat some of the form fields(or form groups) in the survey forms. There should be a + or - button next to the field that if the user clicks on +, then a new field is created.
Example: https://www.rhyzz.com/repeatable-fields.html
I would be surprised to know if Qualtrics doesn't have this feature.
I google for this but no success.
You can't create new fields (choices, answers, variables, etc.) on the fly in Qualtrics. A field has to be defined in the survey for it be be saved in the response data.
You could write a JavaScript to show and hide fields to give the appearance of adding and removing fields, but you would have to define the maximum number of fields in the survey beforehand.

Sharepoint - Load a form's view based on user

I am using a data connection list to load desired views in an InfoPath form on SharePoint. I have a permission list with 2 columns: usernames and control group. My form on the main list loads a specific view based on what the username and group are of the permission list. You have to filter out the group based on the form's username() function to match the username column and set that as a condition to (on form load) change it to a specific view.
All this works, but the problem comes in when you have a user with multiple control groups. The filter only returns the first instance it finds. I can't think of a way to fix this. Maybe load the other list as a repeating table into the form, but then how would I reference that table in the conditions of a form load rule? Or is there a way to get a field filter to look past the first item it finds?
Update: I forgot to mention that I have to use a field to hold your filtered username:id:group aka group[title=username()] and then use that in the form load conditions. I think this is where the problem is, as this filter is what doesn't store all instances of the users id from the control list, but only the first.
SharePoint 2010 with forms created in InfoPath 2010
Are you querying the data in from info path or using visual studio, if you are querying in info path check the condition as Display name matches the username() and the query the data