Skip to main content
March 31, 2022
Question

Bar chart user filter validation

  • March 31, 2022
  • 4 replies
  • 0 views

Hi there !

So... I've created a bar chart with some custom fields filters. Now, I'm trying to create a validation for 2 date fields, since they're about date interval and I wanna validate if the second one isn't greater than first one, for example.

I created some validations on field, using "validations" property. It shows error mesage, but still filter chart's data.

Here is the point: I wanna prevent it. Doing a analogy to web development, I wanna prevent the load event.

Is it possible ?

4 replies

gopalk2865
March 31, 2022

HI Bruno, If you are querying data based on filters then add the date validation condition  while querying the data as well. i suppose you are querying data in a local variable , if so then add a conditon in the filter parameter based on date validation. below is an basic example ,

a!localVariables(
  local!data:a!queryEntity(
    entity: cons!entity_emp,
    query: a!query(
      pagingInfo: a!pagingInfo(startIndex: 1,batchSize: -1),
      filter: a!queryFilter(
        field: "id",
        operator: "=",
        value: ri!id,
        applywhen: local!startDate

March 31, 2022

Ty 4 reply !

Sorry, maybe I wasn't so clear: I wanna validate the inputs, instead the result. If user's input not satisfy my condition, report shouldn't to refresh. Pretty much like Javacript validation, preventing a post.

March 31, 2022

Hi Bruno,

Given what you're looking for I would do an if() statement within the saveInto. Something like the below. You can also have an validation parameter that shows up as expected when this happens so the user knows, you'd just have to validate based on the tempDate variable.

saveInto: {
local!tempDate,
    if(
        local!tempDate>local!dateTwo,
        a!save(local!tempDate, null),
        a!save(local!dateOne, local!tempDate)
    )
}

mikes0011
Brainy
March 31, 2022

You could set it such that the filters are only applied to the report data query after the user clicks a button/link i.e. "Apply" (or whatever you'd like to label it).  Instead of (and/or in addition to) validating on the filter input, you could simply leave the button/link inactive if the filter conditions are unacceptable.