Changing a variable solely based on the input of another variable

So I collect a variable with an array of activity codes as an array. I need WeWeb to classify this array into a pricing tariff.

The logic here is pretty simple (check screenshot 2 below), if all activity codes in the array are in a single cluster = display this cluster in the variable 02_Activity_Tariff. If multiple activity codes are mentioned which classify into more than one cluster = display ‘highCare’ in the variable 02_Activity_Tariff.

I need this because because a lot of my conditional logic will be based individual activities AND tariffs so I need both of these variables correctly defined to build the logic.

I will generate the array of activity codes from URL parameters so I don’t think I can build this through Xano. Or maybe that is the solution after all?

Hi @paulgassner :wave:

I didn’t understand the question. Would you mind rephrasing it?

Hey Joyce, sorry about my question not being entirely clear. I made this quick video to explain what I am trying to accomplish

You’ll need to work with both Activity Code and Tariff in the first one ideally, because you need to identify if there is a discrepancy in tariffs. What I would do, there is two ways:

1. Make a third variable called helperTariff or something, and get all the tariffs there so for example you on click / change whatever add all the tariffs to this array, so if you have three activities, it will look like this

[1,1,1] - check on this with javascript, if all of them are the same. If this check is true, you set the variable 02_Activity_Tariff to your Tariff, else set it to five if it is for example [1,2,1].

2. Save the Activity into Activity_Code as an object e.g [{“id”: “71222.a”, “tariff”: 1}, …] and do the same check you did in 1. but summing the Tariffs as object property.

1 Like