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
  • If I understand your use case correctly, you want to perform the above same operation when you have "multiple" values in your constant unlike single value which you said is working for you.
    If yes, then just simply refer to the index of your constant array against which you want to match your search results for.
    For instance, from your above stated example, if you want to show the paragraph for "This product licence is perpetual." to match it against a value (product code) sitting in the constant at lets say index '2' then your code would be..

    if(
    index(
    ri!ItemList,
    "productCode",
    ""
    ) = cons!MY_SOFTWARECODE[2],
    a!paragraphField(
    value: "This product licence is perpetual.",
    readOnly: true
    ),
    a!paragraphField(
    value: "No match.",
    readOnly: true
    )
    )
                        
                        
    >> Other approach, if you think that the ordering of the values in the constant array should not matter, then you code should look something like:
    if(
    index(
    ri!ItemList,
    "productCode",
    ""
    ) =
                         /*Updated block code BEGIN*/
                         index(cons!MY_SOFTWARECODE,wherecontains(<value to search for>,cons!MY_SOFTWARECODE),{}),
                         /*Updated block code END*/

                         a!paragraphField(
    value: "This product licence is perpetual.",
    readOnly: true
    ),
    a!paragraphField(
    value: "No match.",
    readOnly: true
    )
    )
                        
    Hope it helps or let me know if I misunderstood your problem.
                        
Reply
  • If I understand your use case correctly, you want to perform the above same operation when you have "multiple" values in your constant unlike single value which you said is working for you.
    If yes, then just simply refer to the index of your constant array against which you want to match your search results for.
    For instance, from your above stated example, if you want to show the paragraph for "This product licence is perpetual." to match it against a value (product code) sitting in the constant at lets say index '2' then your code would be..

    if(
    index(
    ri!ItemList,
    "productCode",
    ""
    ) = cons!MY_SOFTWARECODE[2],
    a!paragraphField(
    value: "This product licence is perpetual.",
    readOnly: true
    ),
    a!paragraphField(
    value: "No match.",
    readOnly: true
    )
    )
                        
                        
    >> Other approach, if you think that the ordering of the values in the constant array should not matter, then you code should look something like:
    if(
    index(
    ri!ItemList,
    "productCode",
    ""
    ) =
                         /*Updated block code BEGIN*/
                         index(cons!MY_SOFTWARECODE,wherecontains(<value to search for>,cons!MY_SOFTWARECODE),{}),
                         /*Updated block code END*/

                         a!paragraphField(
    value: "This product licence is perpetual.",
    readOnly: true
    ),
    a!paragraphField(
    value: "No match.",
    readOnly: true
    )
    )
                        
    Hope it helps or let me know if I misunderstood your problem.
                        
Children
No Data