Question about constans, proccess models, and expression

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

Parents Reply Children
  • 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.

  • 0
    Certified Lead Developer
    in reply to Gustavo Silva

    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