Need to add filter in queryEntity

Hi ,

I want to add filter condition  from interface to expression rule(Query Entity). In existing scenario on interface i am using below code to display error message .

Now same functionality i want to achieve at query entity filter condition. I want to filter my data at first level only instead to pop error message on interface.

Can you help me to add below condition in query entity. 

Filter Condition which need to be add on Query-

count(
rule!getValidationFilter(
index(
ri!masterDataSet,
"nameID",
{}
)
)
) >= 1

Basically i want to apply above rule in query entity . Master data should be filter out where count is greater then 1 or equal 1.

QUery Entity-

a!queryEntity_18r3(
entity: cons!MASTER_TABLE,
query: a!query(
logicalExpression: a!queryLogicalExpression(
operator: "AND",
filters: {
if(
rule!APN_isBlank(
ri!nameID
),
{},
a!queryFilter(
field: "nameID",
operator: "=",
value: ri!nameID
)
)
}
),
pagingInfo: local!pagingInfo
)
),

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    1. Your code snippets would be a lot easier to read if you use a Code Box ("insert" --> "insert code"), as this retains indent formatting as well as using a friendlier font for code-reading
    2. Assuming I understand what you're getting at here, I am unaware of any filtering that's directly usable in a!queryEntity that will filter based on repetitions of a particular value in a table.
      1. If you're just dealing with one specific nameID (per instance) and want to display a particular error message when it's repeated more than once in the table, you should simply be able to take the .totalCount property of the resulting DataSubset and use your logic on that.  I'll attempt to post an example below.
      2. If you're trying to handle mulitple nameIDs at once, you might need to query separately for each nameID.

    Example:

    a!queryEntity(
      entity: cons!MASTER_TABLE,
      fetchtotalcount: true(),
      query: a!query(
        logicalExpression: a!queryLogicalExpression(
          operator: "AND",
          filters: {
            a!queryFilter(
              field: "nameID",
              operator: "=",
              value: ri!nameID,
              applywhen: not(rule!APN_isBlank(ri!nameID))
            )
          }
        ),
        pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 0)
      )
    ).totalCount >= 1

  • I'd also suggest adding information about what you want your outcome to be without discussing a!queryEntity() at all - there's potentially a lot of possibilities with queries, so knowing something like "I'd like to validate that this text field doesn't already have the same value in the database" or whatever your original issue is can help us provide a good solution.

Reply Children
No Data