Hi,
I need help, well I need to make an evaluation from a process some data of a constant, this constant contains two decimal data.
I have something like this
With(
Pv!httpCall=200,
Pv!evaluate<cons!DATA_TO_EVAL
)
Assuming that my constant DATA_TO_EVAL, currently has only one data, I need to put two data in it,
Before I put two data to that constant, (originally it had 100, now in an array that constant has 100 and 50)
How can I do that evaluation from my process parameters as expression
I have tried doing an if
If(
cons!DATA_TO_EVAL,100," IS HIGHER"
But I don't get what I need, I don't know if I made myself clear, thank you very much...
Discussion posts and replies are publicly visible
Did you consider to use a foreach to evaluate that process value against each of the values in the constant?
Gustavo Silva said:If( cons!DATA_TO_EVAL,100," IS HIGHER" )
What you are trying to do here? If you simply compare it just like how you did when it had single item i.e., Pv!evaluate<cons!DATA_TO_EVAL then also it will compare all items in that constant with pv and return list of boolean values.
a!foreach( item:cons!constant, expression:if(pv!data<fv!item, true(), false()) ). Map these boolean result to some process variable use it else where for condtions OR {200}<{100,50} returns {true, true} map it to pv and use it elsewhere
I tried with another solution where from the constant, sending it to call, I selected for exampleassuming my constant has two values: {89}, I needed the index of the first value, in this case Cons!MY_CONSTANT_VALUE[1],
I think that for the requirements this is the solution that I needed... I still appreciate your support Stefan.
Hi, I tried a different solution I think I was not given the explanation of what I needed in the requirement, so I used something similar to thisassuming my constant is an array of 2 digits{89}cons!MY_CONSTANT_DEMO[1], according to the option I needed, I only required the first item, and well, I still appreciate your support.
If I understood correctly, I think this is what you are looking for.
Essentially, if all the items in the array meet a condition, it returns true, otherwise false. If you only need 1 item to be true, simply change the and() for an or(). You can adjust the condition to whatever you require.
and( a!forEach( items: { 200, 200, 200 }, expression: fv!item = 200 ) )
This is exactly a case for which I recommend to NOT use a constant with multiple values. Why?
When not using any constants, your code would be like this:
if(local!value > 42, dothis, dothat)
When using a constant with multiple values, it is this:
if(local!value > cons!WHATEVER[7])
This does not make your code any more readable and still ties the functionality of your code to a hard coded value. In this case the index number.
My approach is:
- Create a constant for each value giving it a great name
- When a list of these values is needed, create an expression that creates that list.
You now have readable code and no dependencies on hard coded values