How to filter negative values from readonly grid

I have a requirement to filter negative values from readonly  grid and It needs to get configured from expression rule but Im not able to filter the negative values.

I tried using "<" as operator for that particular field but still not filtering out.

please help me achieve this

  Discussion posts and replies are publicly visible

Parents
  • Please share the actual code you've tried so we can make informed comments.  Generally an a!queryFilter(), when filtering on a numeric value, should accept the "<" operator just fine, but any number of other things could have gone wrong before it even gets that far, and it's hard to guess without seeing exactly what you've tried and exactly what went wrong.

  • hi mike thankyou for responding

    my requirement is I have to make a filter for latitude and longitude as latitude from latitude to and longitude from longitude to when user put some values in latitude from and latitude to then it filters the values between those values from grid

    for reference : 

    here i wan values above 42 as well like 42.2 but just getting values between 41 and 42
    if there is any solution please let me know

  • if you want a value like 42.2 to be included then your "to" filter entry should be 43.  Or you could just override the filter value and add 1 to whatever the user enters, so it would match all values up to the next higher integer (you'd just need to test it well to make sure different corner cases work like you expect).

  • but the requirement is that user can enter any value like 41 and 42 but grid should give values till 42.99 .

    is it possible to make chnages in expression rule so that if user puts 41 and 42 then grid could give values like 42.5 or something like that?

    user should be sorted in his mind if he enters value 41 and  42 then any value around 42 will be populated like 42.2 or 42.4 etc

  • but the requirement is that user can enter any value like 41 and 42 but grid should give values till 42.99

    ok, and that's why i said this:

    Or you could just override the filter value and add 1 to whatever the user enters, so it would match all values up to the next higher integer

    Did you try that already?

  • I didnt get you, you mean to say i have to use sum() add 1 to selected value ?

    as I have tried on selectedvalue as

    sum(local!selectedLatititudeTo,0.9)

  • you mean to say i have to use sum() add 1 to selected value ?

    sum() doesn't really play into this.  you can simply add 1 to the user-entered value when feeding it into your queryFilter.  If you're not sure how to do that, you can post the actual code from your queryfilter and i can tell you how to modify it.  Generally you'd put something like,

    a!queryFilter(
      field: "latitude",
      operator: "<",
      value: ri!userSelectedValue + 1
    )

  • but according to the above solution result could be like this:

    if user enters 41 and 42 then grid will display value between 41 and 43?

  • 42 then grid will display value between 41 and 43?

    If the user enters an upper value of 42 and you add 1 to it when actually performing the filter, as in my example code above, and the operator is "<", that means any values less than 43 will be returned, up to and including i.e. "42.999" etc.  For the lower-end filter you would want to use the ">=" filter and just pass the user's original value, i.e. it would start matching values at 41 and all incrementals above that (41.00001, 41.3, 41.9, 42, 42.5, etc).

  • can you please tell me how can I apply on my code:

    here data type of lat from ,lat to and long from long to is decimal

    and On interface I have taken floatingpointfield value

    my UI looks like this 

    /*range between latitude from and latitude to*/
    
    a!queryFilter(
            field: 'recordType!{9441efd7-521a-4695-82a7-d661a237c67d}SLS Site Sync.fields.{499d2d44-21c8-41dc-a3be-2dbd3ee0356f}absY',
            operator: ">=",
            value: ri!latFrom,
            applyWhen: and(
              not(
                rule!APN_isEmpty(ri!latFrom)
              ),
              rule!APN_isEmpty(ri!latTo)
            ),
          ),
          a!queryFilter(
            field: 'recordType!{9441efd7-521a-4695-82a7-d661a237c67d}SLS Site Sync.fields.{499d2d44-21c8-41dc-a3be-2dbd3ee0356f}absY',
            operator: "<=",
            value: ri!latTo,
            applyWhen: and(
              not(
                rule!APN_isEmpty(ri!latTo)
              ),
              rule!APN_isEmpty(ri!latFrom)
            ),
          ),
          a!queryFilter(
            field: 'recordType!{9441efd7-521a-4695-82a7-d661a237c67d}SLS Site Sync.fields.{499d2d44-21c8-41dc-a3be-2dbd3ee0356f}absY',
            operator: "between",
            value: {
              ri!latFrom,
              ri!latTo
              },
              applyWhen: and(
                not(isnull(ri!latFrom)),
                not(isnull(ri!latTo))
              ),
          ),
          
          
         /* range between longitude from and longitude to*/
         
               a!queryFilter(
            field: 'recordType!{9441efd7-521a-4695-82a7-d661a237c67d}SLS Site Sync.fields.{eb9a14a1-50e1-4d5a-9d81-ca3a8db3563c}absX',
            operator: ">=",
            value: ri!longFrom,
            applyWhen: and(
              not(
                rule!APN_isEmpty(ri!longFrom)
              ),
              rule!APN_isEmpty(ri!longTo)
            ),
          ),
          a!queryFilter(
            field: 'recordType!{9441efd7-521a-4695-82a7-d661a237c67d}SLS Site Sync.fields.{eb9a14a1-50e1-4d5a-9d81-ca3a8db3563c}absX',
            operator: "<=",
            value: ri!longTo,
            applyWhen: and(
              not(
                rule!APN_isEmpty(ri!longTo)
              ),
              rule!APN_isEmpty(ri!longFrom)
            ),
          ),
          a!queryFilter(
            field: 'recordType!{9441efd7-521a-4695-82a7-d661a237c67d}SLS Site Sync.fields.{eb9a14a1-50e1-4d5a-9d81-ca3a8db3563c}absX',
            operator: "between",
            value: {
              ri!longFrom,
              ri!longTo
            },
            applyWhen: and(
              not(isnull(ri!longFrom)),
              not(isnull(ri!longTo))
            ),
          ),

Reply
  • can you please tell me how can I apply on my code:

    here data type of lat from ,lat to and long from long to is decimal

    and On interface I have taken floatingpointfield value

    my UI looks like this 

    /*range between latitude from and latitude to*/
    
    a!queryFilter(
            field: 'recordType!{9441efd7-521a-4695-82a7-d661a237c67d}SLS Site Sync.fields.{499d2d44-21c8-41dc-a3be-2dbd3ee0356f}absY',
            operator: ">=",
            value: ri!latFrom,
            applyWhen: and(
              not(
                rule!APN_isEmpty(ri!latFrom)
              ),
              rule!APN_isEmpty(ri!latTo)
            ),
          ),
          a!queryFilter(
            field: 'recordType!{9441efd7-521a-4695-82a7-d661a237c67d}SLS Site Sync.fields.{499d2d44-21c8-41dc-a3be-2dbd3ee0356f}absY',
            operator: "<=",
            value: ri!latTo,
            applyWhen: and(
              not(
                rule!APN_isEmpty(ri!latTo)
              ),
              rule!APN_isEmpty(ri!latFrom)
            ),
          ),
          a!queryFilter(
            field: 'recordType!{9441efd7-521a-4695-82a7-d661a237c67d}SLS Site Sync.fields.{499d2d44-21c8-41dc-a3be-2dbd3ee0356f}absY',
            operator: "between",
            value: {
              ri!latFrom,
              ri!latTo
              },
              applyWhen: and(
                not(isnull(ri!latFrom)),
                not(isnull(ri!latTo))
              ),
          ),
          
          
         /* range between longitude from and longitude to*/
         
               a!queryFilter(
            field: 'recordType!{9441efd7-521a-4695-82a7-d661a237c67d}SLS Site Sync.fields.{eb9a14a1-50e1-4d5a-9d81-ca3a8db3563c}absX',
            operator: ">=",
            value: ri!longFrom,
            applyWhen: and(
              not(
                rule!APN_isEmpty(ri!longFrom)
              ),
              rule!APN_isEmpty(ri!longTo)
            ),
          ),
          a!queryFilter(
            field: 'recordType!{9441efd7-521a-4695-82a7-d661a237c67d}SLS Site Sync.fields.{eb9a14a1-50e1-4d5a-9d81-ca3a8db3563c}absX',
            operator: "<=",
            value: ri!longTo,
            applyWhen: and(
              not(
                rule!APN_isEmpty(ri!longTo)
              ),
              rule!APN_isEmpty(ri!longFrom)
            ),
          ),
          a!queryFilter(
            field: 'recordType!{9441efd7-521a-4695-82a7-d661a237c67d}SLS Site Sync.fields.{eb9a14a1-50e1-4d5a-9d81-ca3a8db3563c}absX',
            operator: "between",
            value: {
              ri!longFrom,
              ri!longTo
            },
            applyWhen: and(
              not(isnull(ri!longFrom)),
              not(isnull(ri!longTo))
            ),
          ),

Children
  • can you please tell me how can I apply on my code

    I'm not sure I understand.  If you're allowing the user to enter decimal filter values, the code you have here looks like it'll work basically as expected.

    If a user enters "41.8" for instance on the "From" value, wouldn't they expect to ONLY see values from "41.8" and higher?  What are you expecting to happen that isn't happening?

    As an aside, one other thing I'd point out is, you shouldn't really need to do this bending-over-backwards to switch to the "between" operator; you can just use the "from" and "to" individual filters by themselves and when a user has both entered, they'll simply both apply, functionally taking care of a "between" operation on their own, and without having to have so many conditions on all the operators.

  • you mean to say my operator for both from to is correct only i have to remove between condition and to remove applywhen condition to specific from to else nothing to change right?

  • I mean you can generally replace the "between" operation just by having "from" and "to" operations separately that both activate when they're required - when both of them activate at the same time, they will "stack" with each other (presuming that your logicalExpression is using the "AND" joiner), and essentially behave like the "between" operation.  So it's redundant.  But I assume this does not necessarily answer your main question here - just a tip for efficiency in coding filters.

    you mean to say my operator for both from to is correct only i have to remove between condition and to remove applywhen condition to specific from to else nothing to change right?
  • so can you please tell me is it possible if:

    user enters single value in from and to : example 41 and 42 then grid should show value as 41, 41.5, 42, 42.9

    and if user enters decimal value in from to : example 41.4 and 42.3 then grid should display as 41.5, 41.9, 42.2 but not 42.9 

  • example 41.4 and 42.3 then grid should display as 41.5, 41.9, 42.2 but not 42.9 

    This sounds confusing to users (i.e. entering "42" would match "42.9", but entering "42.1" wouldn't match anything higher than 42.1) - however it should be possible to code.  in your filter logic you could take steps to determine whether the entered value is a non-decimal value (note i'm just talking about the value, not the data type), and if so, add 1 to the value when executing the filter; otherwise, don't add anything to the value.

    As far as how to check whether the entered value is a non-decimal?  it's not straightforward, usually there are tricks using the various math functions.  Maybe "floor(ri!num) = ceiling(ri!num)", meaning if the number rounded up to the next integer is the same as the number rounded down to the next integer, which would only be true (afaik) when the starting number is already an integer.

  • Thankyou so much Mike for your time and valuable information and

    my issue is also resolved as the requirement wasn't decided and after all the conversation requirement came to the point that my previous solution was correct only they wanted  as if user enter any non decimal value 
    example 41 and 42 then on fields it turns out to be 41.00 and 42.00 on field and it was resolved using fixed function on text field and range should be anything between 41 and 42 like 41.4, 41.7, 41.9 but not 42.1