Expression rule error if input does not exist.

Hi Everyone,

Can anyone please tell me how to get rid of error in expression rule when rule input does not exist in the entity parameter in appian.

Thank You

  Discussion posts and replies are publicly visible

Parents Reply Children
  • Here is the rule I used:

    with(
    a!queryEntity(
    entity: cons!TEMS_ENTITY_V_TE_DETAILS,
    query: a!query(
    paginginfo: if(rule!APN_isBlank(ri!pagingInfo) , a!pagingInfo(1, - 1,a!sortInfo(field: "etemId",ascending: true)),ri!pagingInfo),
    logicalexpression: a!queryLogicalExpression(
    ignorefilterswithemptyvalues: true,
    operator: "AND",
    filters: {
    a!queryFilter(
    field: "id",
    operator: "includes",
    value: ri!id
    ),
    a!queryFilter(
    field: "etemId",
    operator: "=",
    value: ri!etemId
    ),

    a!queryFilter(
    field: "eterfId",
    operator: "=",
    value: ri!eterfId
    ),
    a!queryFilter(
    field: "cafNumber",
    operator: "includes",
    value: ri!cafNumber
    ),
    a!queryFilter(
    field: "uniqueId",
    operator: "=",
    value: ri!uniqueId
    ),
    a!queryFilter(
    field: "appianDocumentId",
    operator: "=",
    value: ri!appianDocumentId
    ),
    a!queryFilter(
    field: "caseId",
    operator: "=",
    value: ri!caseId
    ),
    a!queryFilter(
    field: "excursionId",
    operator: "=",
    value: ri!excursionId
    ),
    a!queryFilter(
    field: "excursionRangesId",
    operator: "=",
    value: ri!excursionRangesId
    ),
    a!queryFilter(
    field: "justification",
    operator: "includes",
    value: ri!justification
    ),
    a!queryFilter(
    field: "minObservedTempOfTe",
    operator: "=",
    value: ri!minObservedTempOfTe
    ),
    a!queryFilter(
    field: "maxObservedTempOfTe",
    operator: "=",
    value: ri!maxObservedTempOfTe
    ),
    a!queryFilter(
    field: "maxTotalDurationOfTe",
    operator: "includes",
    value: ri!tlDurationOfTe
    ),
    a!queryFilter(
    field: "dispositionStatus",
    operator: "=",
    value: ri!dispositionStatus
    ),
    a!queryFilter(
    field: "createdBy",
    operator: "includes",
    value: ri!createdBy
    ),
    a!queryFilter(
    field: "approvedByName",
    operator: "includes",
    value: ri!approvedByName
    ),
    a!queryFilter(
    field: "approvedByDate",
    operator: "=",
    value: ri!approvedByDate
    ),
    a!queryFilter(
    field: "approverRole",
    operator: "includes",
    value: ri!approverRole
    ),
    a!queryFilter(
    field: "emailSent",
    operator: "includes",
    value: ri!emailSent
    ),

    a!queryFilter(
    field: "capa",
    operator: "=",
    value: ri!capa
    ),
    a!queryFilter(
    field: "comments",
    operator: "includes",
    value: ri!comments
    ),

    a!queryFilter(
    field: "permittedTeRange",
    operator: "includes",
    value: ri!permittedTeRange
    ),
    a!queryFilter(
    field: "calculatedTime",
    operator: "includes",
    value: ri!calculatedTime
    ),
    a!queryFilter(
    field: "disposition",
    operator: "includes",
    value: ri!disposition
    ),
    a!queryFilter(
    field: "justification",
    operator: "includes",
    value: ri!justification
    ),

    a!queryFilter(
    field: "timeAllowableForFutureExcursion",
    operator: "=",
    value: ri!timeAllowableForFuture
    )
    }
    ),

    ),
    fetchTotalCount: true
    )
    )

  • 0
    Certified Lead Developer
    in reply to shubhamy0001

    Next time please use

    Would you please post the actual error message.

    And please explain what "error in expression rule when rule input does not exist in the entity parameter" means. In your code, the entity is a constant. Why can that be empty?

  • This is the error I get when there is no budget id exists corresponding to etem id passed as rule input:

    Expression evaluation error at function rule!APN_distinct [line 2]: Invalid index: Cannot index property 'budgetId' of type String into type List of Variant

    Code:

    rule!APN_distinct(with(
    a!queryEntity(
    entity: cons!TEMS_ENTITY_LINK_HEADER_BUDGET,
    query: a!query(
    paginginfo: a!pagingInfo(1,-1),
    logicalexpression: a!queryLogicalExpression(
    operator: "AND",
    filters: {
    if(isnull(ri!etemId),
    {},
    a!queryFilter(
    field: "etemId",
    operator: "=",
    value: ri!etemId
    )
    ),
    /*a!queryFilter(
    field: "eterfId",
    operator: "not in",
    value: {""}
    ), */
    if(isnull(ri!budgetId),
    {},
    a!queryFilter(
    field: "budgetId",
    operator: "=",
    value: ri!budgetId
    )
    )
    }
    )
    ),
    fetchTotalCount: true
    ).data.budgetId
    ) )

  • 0
    Certified Lead Developer
    in reply to shubhamy0001

    Please use

    If the query does not return any values, the dot-notation "data.budgetId" breaks. Using index() would help here.

    What is the with() doing?