Check row existence in database using expression rule

Hi,

I am using an expression rule with parameters/filters to fetch data. When we have unmatched filters it is breaking the interface. I am using the below 2 expression rule to fill my drop downs which are cascading in nature. Choice values are concatenated with new items in both the drop downs.

When I select "New Program" in drop down 1, I get the below error as my expression rule returns null.

Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function 'union' parameter 2 [line 88]: Invalid index: Cannot index property 'subProgram' of type Text into type List of Variant

Drop down 1:

choiceLabels: {union((union((rule!retrieveProgram("ABC").data.program),(rule!retrieveProgram("ABC","XYZ").data.program))),cast(type!List,"New Program"))}, 
choiceValues: {union((union((rule!retrieveProgram("ABC").data.program),(rule!retrieveProgram("ABC","XYZ").data.program))),cast(type!List,"New Program"))}, 

Drop down 2:

choiceLabels: {union((union((rule!retrieveSubProgram("ABC","value from dd1").data.subProgram),(rule!retrieveSubProgram("ABC","value from dd1").data.subProgram))),cast(type!List,"New Sub Program"))},
choiceValues: {union((union((rule!retrieveSubProgram("ABC","value from dd1").data.subProgram),(rule!retrieveSubProgram("ABC","value from dd1").data.subProgram))),cast(type!List,"New Sub Program"))}, 

Is there way to check row existence in expression rule, so that I can pass a dummy value when the row count is 0? tried totalCount & count functions but no success yet.

I am a beginner in APPIAN, request you to share detail response.

Thanks very much!

Reg/Mp

  Discussion posts and replies are publicly visible

Parents
  • Please try with below snippet. This should work.

    choiceLabels: {
    union(
    union(
    index(
    rule!retrieveSubProgram(
    "ABC",
    "value from dd1"
    ).data,
    "subProgram",
    null
    ),
    index(
    rule!retrieveSubProgram(
    "ABC",
    "value from dd1"
    ).data,
    "subProgram",
    null
    )
    ),
    cast(
    type!List,
    "New Sub Program"
    )
    )
    },
    choiceValues: {
    union(
    union(
    index(
    rule!retrieveSubProgram(
    "ABC",
    "value from dd1"
    ).data,
    "subProgram",
    null
    ),
    index(
    rule!retrieveSubProgram(
    "ABC",
    "value from dd1"
    ).data,
    "subProgram",
    null
    )
    ),
    cast(
    type!List,
    "New Sub Program"
    )
    )
    },

    And you can try testing the specific expression rule by opening it in design mode and pass values(which will have row count as zero) to it.
  • Thanks a lot amanit, it worked for me. super!
Reply Children
No Data