Skip to main content
September 27, 2024
Question

Cannot apply operator - Edited code

  • September 27, 2024
  • 8 replies
  • 0 views

Hi ,

Can anyone please help me with this issue! Thanks for the help in advance.

I have an interface , i have used a!gridfield(). In the grid of the column is the date received. The error says that at function a!gridfield cannot apply operator[LESS THAN] to field [Daterecieved] when comparing to value [TypedValue[it=7,v=2024-09 -27]

a!gridColumn(
  label: "Average customer rating",
  backgroundColor: a!match(
    value: tointeger(today()-todate("9/11/2024 12:00 AM"))
    whenTrue: fv!row < 10,
    then: "NEGATIVE",
    whenTrue: fv!row > 20,
    then: "SUCCESS"
    default: "NONE"
),

Here in above value: I am calling fv!row[recordtype!abc,daterecieved] , above is just a single value.

Thanks for your responses . But Sorry my bad , its actually fv!value which i have given.

Below is the code:

a!gridField(
label:"Rating Grid",
data:local!data,
columns:{
a!gridColumn(

label: "Average customer rating",
sortField: recordType!rating.datarecieved],
value:a!tagField(
label:"tags",
tags: a!TagItem(
text:tointeger ( today() -todate(fv!row[recordtype!ratings.daterecieved])),

backgroundColor: a!match( value: tointeger(today()-todate(fv!row[recordtype!ratings.daterecieved]),
whenTrue: fv!value < 10,
then: "NEGATIVE",
whenTrue: fv!value > 20,
then: "SUCCESS" ,
default: "NONE"

),
},
)

So basically , I am getting the data from expression rule saving it in the local variable and then using it . So here , based on the date received i am calculating how many days  it is and based on that i am showing the background color. But when i am trying to , its throwing me the error : Cannot apply operator ( As shown above )  

    8 replies

    mikes0011
    Brainy
    September 27, 2024

    Why are you using a!match() but then not actually referencing the value parameter (via fv!value) in either of the whenTrue statements?  "fv!row" will be the entire data row, which you probably can't just use in a normal number comparison like "< 10", etc.

    kumara0180
    September 28, 2024

    Basically you have a typo. Instead of using fv!value you have used fv!row. 

    somasundaram.d
    September 28, 2024

    You need to make couple of changes. Replace fv!row with fv!value. Change the background color from "NEGATIVE" to "ERROR"

    backgroundColor:  a!match(
                          value: tointeger(today()-todate("9/11/2024 12:00 AM")),
                          whenTrue: fv!value < 10,
                          then: "ERROR",
                          whenTrue: fv!value > 20,
                          then: "SUCCESS",
                          default: "NONE"
                        )

    mikes0011
    Brainy
    September 30, 2024
    [quote userid="74989" url="~/discussions/f/user-interface/37613/cannot-apply-operator---edited-code"]todate(fv!row[recordtype!ratings.daterecieved]))[/quote]

    Why are you wrapping fv!row[...dateReceived] in todate()?  Wouldn't the row's dateReceived column already be a date type?  Or does it actually contain text that can be safely passed into the toDate() rule?

    September 30, 2024

    I am using it coz : For eg : Date received " 9/11/2024 12:00 AM GMT" is one sample data . So here i am trying todate to get date i,e -- 9/11/2024 . I am doing today()- todate(" 9/11/2024 12:00 AM ") where we get 19::00:00:00.000 . Now i want only number so i am using to integer. So i am doing  tointeger(today()-todate("9/11/2024 12:00AM")) .... I am doing it coz i can compare based on whether i get output > 10 or < 10 i show different colors as background.

    kumara0180
    October 1, 2024

    Can you try adddays("YOURDATE",10)>now() and adddays(now(),-10)<today()  .That should help you compare the values.