I'm working on a travel price list function where I need to check if a customer inquiry matches a price list entry.
The price list entry has a destination position (geolocation) and a radius (number), the radius specifies how many kilometers from the destination position the price list entry is valid for.
The inquiry has a destination position (geolocation), and my task is to find the price list entry that this inquiry position fits into by checking if the destination position goes into any price list area (position with radius).
My SOQL goes like this:
select Id,Name from Fixed_price__c where distance(Destination_position__c, geolocation(59.29751613,18.08904094), 'km') < Destination_radius__c
The geolocation lat and long values are the inquiry coordinates, they are inserted to the query by apex code.
This SOQL gets a parsing error when I use Destination_radius__c instead of a fixed value, it seems that I cannot compare a distance with the field Destination_radius__c? I have Googled around and cannot find anything about this.
The other solution would be to select all Fixed_price__c rows and do a comparison in apex of course, but a single query like the one above would be nicer.
Is this a limitation in the SOQL, or is there any workaround?