Hi All , How to create a expression Rule where I want to check single or multiple mobile number is present or not in a DB .
Ex 1234,4567 present in a data base . If these two are there then return true else false
Discussion posts and replies are publicly visible
Hi,
You can use the a!queryEntity() function to retrieve data from the database with the values as filters and based on the results you can return the boolean value.
In that How can I check with Multiple values (two or three) .
Here's a sample code:
a!queryEntity( entity: <DSE_CONSTANT>, query: a!query( logicalExpression: a!queryLogicalExpression( operator: "AND", filters: { a!queryFilter( field: "phoneNumber", operator: "in", value: { "12345", "56789" } ) }, ignoreFiltersWithEmptyValues: true ), pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 50) ), fetchTotalCount: false ).data
if I am creating rule input as array in Expression Rule and then I put that rule input in value field . will it work for that
Yes, it will work.
I am getting this Error
Expression evaluation error at function a!queryEntity [line 2]: An error occurred while retrieving the data. Details: Unexpected error executing query (type: [TWMDecomRequestSitesDT12021], query: [queryentity expression], order by: [[Sort[newlocationsiteid asc]]], filters:[(siteid in TypedValue[it=103,v={AB000,AB0001}])])
Can you please share your code?
if( a!queryEntity( entity:<DSE_Constant>, query: a!query( logicalExpression: a!queryLogicalExpression( operator: "AND", filters: { a!queryFilter( field: "siteid", operator: "in", value:{"AB000","AB0001"} ) }, ignoreFiltersWithEmptyValues: true ), pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 50) ), fetchTotalCount: false).data,"Present","Not Present")
Please help
This error might occur due to several reasons. Please validate the points discussed in this thread-community.appian.com/.../unexpected-error-executing-query
is the code is correct . I dont have nay thing right now in the database . I just trying to create an expression rule
The code has no issues, but you need to add a null check like below to achieve your requirement:
if( isnull( a!queryEntity( entity: < DSE_Constant > , query: a!query( logicalExpression: a!queryLogicalExpression( operator: "AND", filters: { a!queryFilter( field: "siteid", operator: "in", value: { "AB000", "AB0001" } ) }, ignoreFiltersWithEmptyValues: true ), pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 50) ), fetchTotalCount: false ).data ), "Not Present", "Present" )
Hi Selvakumar , Is this code test both values in an array one by one . If one value is present in an table and other is not there . What will happen this case
Hope the below code helps
a!localVariables( local!dataSet: a!queryEntity( entity: "< DSE_Constant >", query: a!query( logicalExpression: a!queryLogicalExpression( operator: "AND", filters: { a!queryFilter( field: "rollnumber", operator: "in", value: { "AB000", "AB0001" } ) }, ignoreFiltersWithEmptyValues: true ), pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 50) ), fetchTotalCount: true ), if( local!dataSet.totalCount = length({ "AB000", "AB0001" }), true(), false() ) )