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])])

Reply
  • 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])])

Children