0

I found an interesting bug when trying to query for a Campaign based on the NumberSent field. When executing the following query I'm receiving 'Illegal Integer' error:

system.debug([select id from Campaign where NumberSent = 5544022491]);

However, when I change the number e.g. to 1544022491, the query works. It seems like a Salesforce issue. What are your thoughts? Worth to mention is that I'm facing the same issue no matter what field of type Number I use in the SOQL for the filter.

1 Answer 1

1

The maximum size of a 32-bit signed integer is 2,147,483,647 (231 - 1). That's why one of them works and the other doesn't.

NumberSent is actually stored as a Double, not an Integer, so you could try NumberSent = 5544022491.0 instead.

5
  • 5544022491.0 actually does not work. I mentioned here NumberSent field just as an example. In our project we use Variable__c custom Number field instead, that I need to use in the mentioned filter query (filtered by 5544022491 variable number). What will be the workaround then? Commented Jun 30, 2023 at 11:00
  • In what way doesn't it work? I've just tried it myself and the query runs fine. The workaround would be to convert it from an Integer to a Double.
    – fred
    Commented Jun 30, 2023 at 11:21
  • 1
    Yep, can confirm that this is the way to handle this. You can also use a Long, though really only via a bind in Apex (the query engine behind SOQL does not understand Long literals, so something like WHERE NumberSent = 5544022491L will unfortunately not work)
    – Derek F
    Commented Jun 30, 2023 at 11:30
  • Ok, it looks liek this workaround works in apex. Thanks a lot for your help. However I didn't mention that I use this query in Flow Get Record action. And that is where it fails. This is the error message: This error occurred when the flow tried to look up records: (((Variable_No__c = 5544022491) I also tried to save the number to Number variable and use it in the get record action, but it didn't work either. Do you know a workaround for this use case? Commented Jun 30, 2023 at 12:26
  • Ok I solved the error using Apex defined Double variable. Thanks a lot! Commented Jun 30, 2023 at 13:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .