I have a CDT which can contain an array of product information and a Constant wh

I have a CDT which can contain an array of product information and a Constant which contains specific product codes. In my user interface, I can display a specific piece of text where the value of CDT.fieldname = cons!value, however it only works if the Constant contains a single value. How can I perform a match where there are multiple values in the constant. In my form, I have the following:

if(
index(
ri!ItemList,
"productCode",
""
) = cons!MY_SOFTWARECODE,
a!paragraphField(
value: "This product licence is perpetual.",
readOnly: true
),
a!paragraphField(
value: "No match.",
readOnly: true
)
)

The CDT ItemList contains the fields productCode, productName, price.

The constant contains the values Word123,Excel123

As the user is filling the form and picks a product that mat...

OriginalPostID-203840

OriginalPostID-203840

  Discussion posts and replies are publicly visible

Parents
  • @andyb Hi, there could be various ways to do as specified above by other practitioners. But it would be worth knowing about the behavior of the if() in case of your example.

    So let's take the 'condition' argument of the if() in your example which is as follows:
    index(ri!ItemList, "productCode","") = cons!MY_SOFTWARECODE

    Here, index(ri!ItemList, "productCode","") returns results in a list format. And cons!MY_SOFTWARECODE also returns results in list format. Thereby ultimately you end up in returning a list of boolean values after comparing both the lists and these list of boolean values will be passed to 'condition' argument of if(). Execute the following examples in the expression editor and see the results, and they are the results that will be used as condition in if().

    Example 1: index({{productCode:"SWCODE1"},{productCode:"SWCODE2"},{productCode:"SWCODE3"}},"productCode",{}) = {"SWCODE2","SWCODE3","SWCODE1"}
    Example 2: index({{productCode:"SWCODE2"},{productCode:"SWCODE2"},{productCode:"SWCODE3"}},"productCode",{}) = {"SWCODE2","SWCODE3","SWCODE1"}


    if() function returns 'valueIfTrue' or 'valueIfFalse' as long as the 'condition' argument isn't in a list format. But if the 'condition' argument is in List format, then if() function behaves differently and it has been mentioned in the 'Notes' section at https://forum.appian.com/suite/help/16.1/Logical_Functions.html#if.28.29.

    Also I believe that a decent discussion has took place at /search?q=OriginalPostID-146293 re the behavior of if() when list is used as condition.
Reply
  • @andyb Hi, there could be various ways to do as specified above by other practitioners. But it would be worth knowing about the behavior of the if() in case of your example.

    So let's take the 'condition' argument of the if() in your example which is as follows:
    index(ri!ItemList, "productCode","") = cons!MY_SOFTWARECODE

    Here, index(ri!ItemList, "productCode","") returns results in a list format. And cons!MY_SOFTWARECODE also returns results in list format. Thereby ultimately you end up in returning a list of boolean values after comparing both the lists and these list of boolean values will be passed to 'condition' argument of if(). Execute the following examples in the expression editor and see the results, and they are the results that will be used as condition in if().

    Example 1: index({{productCode:"SWCODE1"},{productCode:"SWCODE2"},{productCode:"SWCODE3"}},"productCode",{}) = {"SWCODE2","SWCODE3","SWCODE1"}
    Example 2: index({{productCode:"SWCODE2"},{productCode:"SWCODE2"},{productCode:"SWCODE3"}},"productCode",{}) = {"SWCODE2","SWCODE3","SWCODE1"}


    if() function returns 'valueIfTrue' or 'valueIfFalse' as long as the 'condition' argument isn't in a list format. But if the 'condition' argument is in List format, then if() function behaves differently and it has been mentioned in the 'Notes' section at https://forum.appian.com/suite/help/16.1/Logical_Functions.html#if.28.29.

    Also I believe that a decent discussion has took place at /search?q=OriginalPostID-146293 re the behavior of if() when list is used as condition.
Children
No Data