How do I go about hiding dynamic results from a server connect query using App Connect.
Example:
I want to get all possible products that my customer can order and then I want another server connect to get all the products that my customer has already ordered. Then App Connect should hide the products that are already ordered and only show me the products that have not been ordered.
You can do this server side with a single server action and 2 database queries.
You can filter a query based on the user id and return the users products. In another query, just after this one you can filter the products and exclude the ids of the products returned from the users products query using NOT IN.
Then I suppose you could use Array List for that and:
create an ArrayList id=newProducts...
(Define the schema like the products schema)
Then add a new/extra field prd_Sold(boolean) on the newProduct ArrayList (you see why at the next step)
Create a repeat on the one products API and compare to the orders(products ordered from client).
Add a condition step and if the product_id exists in the orders api then set the prd_Sold(boolean)==true otherwise false.
This way, you have a query with all the produts and on your page you can filter by prd_Sold==false to show only the products that have not been ordered by the client
Something like that...
*More about Array Lists in this great tutorial from Hyberbytes:
However I have no idea how to do the search/compare between the 2 datasets. Both datasets have a code column which is the id of the product that should be used to compare.
I am comparing the "region_id" and the "code" in the 2 datasets.
What I'm trying to achieve is if the "region_id" is included in the first dataset, then in the 2nd dataset that same "code" should show as false in the activated field.
@famousmag Everything is working right now. I've gotten the condition to work and show false or true.
But the only issue I have now is that because there a 2 arrays which are being compared, Wappler keeps pulling in and comparing only the first data array. How do I get Wappler to run through the whole entire array data?
It is the 2 arrays that are already taken the values from the 2 APIs?
You have already assign the values of each API in a different Array List witrh an ADD ALL TO Array LIST step?
Anyway, you should click on the region_id you see inside the activations repeat Can you share a screenshot of your serveraction so I can understand what you have so far?
Don't play around my friend...
You just have to understand
a)what you have
b)what you need
then the only thing missing is the HOW to arcieve what you need
Then we add one Array List to hold all the products
give it the schema you want for example:
prod_id
Prod_Name
prod_Code
whichever else column you want and
prod_activated (will hold if the product will be listed or no)
Then add a repeat step based on the activationsAPI.
inside the repeat:
add to the ArrayList columns the product details you want
add a condition and check if the regionsAPI.values('code').contains(region_id)
the region_id you bind it form inside the repeat's content
-if the condition is true (the client has already ordered that product)
you set the ArrayList's prod_activated field equal to true
Otherwise
you set the ArrayList's prod_activated field equal to false
After the Repeat you get the ArrayList value and check the output so you can see it in your page
Now in your page,
add a Serverconnect component, based on the above serveraction.
add a DataView component and
a) set its DataSource to the above arrayList Serveconnect.ArrayListProducts
Up to now the DataView contains all the products
b) if you want to filter them you can set the DataView's filter to prod_activated==true
I hope you understand it...
Start with this guide and if you have problem share a screenshot in order to help you
I believe I'm messing up around these steps. Also should the repeat be a list of all the products and not the activations? And then the condition would check if the product is included in the activation?
Usually I'm really good a Wappler but this is so confusing for me today, and I know I'll have to use this type of query a lot this week.