Check if data exists in database using expression rule

I am trying to create an Expression rule that returns true if a specific piece of data is present in a specific column of a db but I feel like I am not doing it in an efficient way. 

My situation is analogous to this situation:

Database table with employee contact information. Trying to see if 111-222-3333 is present in the phone number column of the table.

I am attaching an image of how I am attempting it and I feel like I am making it more complicated then it should be.

 

Thanks

  Discussion posts and replies are publicly visible

Parents
  • Hi,
    Query entity will always returns a DataSubset of Dictionaries.

    [startIndex=1,
    batchSize=-1,
    sort=,
    totalCount=2,
    data=1; 2,
    identifiers=1; 2]

    So, rather than doing dot notation with a!queryEntity(..).data use the total count parameter to check like a!queryEntity(..).totalCount

    Thanks,
    Vadivelan
  • 0
    Certified Associate Developer
    in reply to Vadivelan

    if(
    property(
    a!queryEntity(
    entity: <cons....>,
    query: a!query(
    selection: a!querySelection(
    columns: {
    a!queryColumn(
    field:"siteid"
    )
    }
    ),
    filter: a!queryFilter(
    field: "siteid",
    operator: "=",
    value: ri!siteid
    ),
    paginginfo: a!pagingInfo(
    startIndex: 1,
    batchSize: 1
    )
    )
    ).totalCount>0,
    "siteid",false)=ri!siteid,
    "Request Already Generated",
    "Request Not Generated"
    )

    I am getting this Error:

    Expression evaluation error at function a!queryEntity [line 3]: An error occurred while retrieving the data. Details: Unexpected error executing query (type: [TWMDecomRequestSitesDT12021], query: [queryentity expression], order by: [[Sort[siteid asc]]], filters:[(siteid = TypedValue[it=3,v=AB000444])])

  • 0
    Certified Lead Developer
    in reply to saurabh sharma

    Your query entity execution is failing. Check your Appian Tomcat Logs, it can provide more information on why query entity call is failing.

  • 0
    Certified Lead Developer
    in reply to saurabh sharma

    Please paste the exact expression code you're attempting to run, and post it in a code box (Insert --> Insert Code), with indentation left in-tact (preferably, run auto-formatting first).

    The code you've posted here is invalid, as you are trying to get the .totalCount property from the result and at the same time (?) get the .siteId property.  It seems as if you combined 2 of the previous examples in this thread without actually understanding how Query Entities work - honestly, it would probably be best if you study the documentation on Query Entity and became familiar with how it works and why, and what its output is and how to use them.

Reply
  • 0
    Certified Lead Developer
    in reply to saurabh sharma

    Please paste the exact expression code you're attempting to run, and post it in a code box (Insert --> Insert Code), with indentation left in-tact (preferably, run auto-formatting first).

    The code you've posted here is invalid, as you are trying to get the .totalCount property from the result and at the same time (?) get the .siteId property.  It seems as if you combined 2 of the previous examples in this thread without actually understanding how Query Entities work - honestly, it would probably be best if you study the documentation on Query Entity and became familiar with how it works and why, and what its output is and how to use them.

Children
No Data