Skip to main content
June 23, 2023
Question

Question about constans, proccess models, and expression

  • June 23, 2023
  • 7 replies
  • 0 views

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...

7 replies

stefanhelzle0001
Brainy
June 23, 2023

Did you consider to use a foreach to evaluate that process value against each of the values in the constant?

June 24, 2023

I tried with another solution where from the constant, sending it to call, I selected for example
assuming my constant has two values:
{
8
9
}, 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.

stefanhelzle0001
Brainy
June 25, 2023

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

June 23, 2023

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.

June 24, 2023

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 this
assuming my constant is an array of 2 digits
{
8
9
}
cons!MY_CONSTANT_DEMO[1],
according to the option I needed, I only required the first item,
and well, I still appreciate your support.

venkatrea696188
June 23, 2023

a!foreach(
item:cons!constant,
expression:if(pv!data

mathieud0001
Brainy
June 24, 2023

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
  )
)