DISTANCE condition does not appear in the soql of the model

  • 2
  • Problem
  • Updated 2 years ago
Hi, 

I have a custom object 'Site__c' with locations I want to retrieve all the products in other Site__c's  where they are less than 1 km of the Site.

So I have made this conditions 



1: I dont want the products of $this.Site__c
2: the site parent of the products is in 1 km
3: only firm quotes.



this is the detail of the Distance filter.

SiteInformation model is the Master/main model in the page. the page shows the information of a Site.

But when I try this, in a site in Germany the 'in less than 1 km firm quotes' pops sites from peru, ecuador, brazil....

After playing with the model definition and discarding that as a problem, playing with the console I have discover that the distance condition is not in the SOQL of the model...:
 
skuid.model.getModel('QuotesNear').soql;

"SELECT Stage__c,Product_Name__c,OSI_ID__c,Base_Currency__c,Total_Install_Charges_BC__c,Total_Monthly_Charges_BC__c,Site__c,Site__r.Name,isOrder__c,Site__r.GpsCoords__c,Site__r.GpsCoords__Latitude__s,Site__r.GpsCoords__Longitude__s,Id FROM Opportunity_Sales_Item__c WHERE (Site__c != 'a0Fb000000Eq6J3EAJ')AND(Stage__c = 'Available and firm quote') LIMIT 11"
So my question is... Why?
Photo of Pablo Martinez

Pablo Martinez

  • 2,468 Points 2k badge 2x thumb

Posted 3 years ago

  • 2
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Check the following about the SiteInformation model:

1. It must come before the QuotesNear Model in your list of Models in the Page Composer. If it is not, drag it up above.
2. Make sure that the GpsCoords__Latitude__s and GpsCoords__Longitude__s fields are in your SiteInformation Model.
Photo of Pablo Martinez

Pablo Martinez

  • 2,468 Points 2k badge 2x thumb
Yes, I have checked that, everything is OK:

siteInformation has the fields in the model


SiteInformation is the first model, QuotesNear the last one:


It was ok since the begining so that's not why.
(Edited)
Photo of Pablo Martinez

Pablo Martinez

  • 2,468 Points 2k badge 2x thumb
no ideas of what is happening?
Photo of Kartik Sethuraman

Kartik Sethuraman

  • 798 Points 500 badge 2x thumb
Does the logged in user have Field Level Security permissions to view all the fields in that condition? Conditions for fields the user can't view are removed from the SOQL.
Photo of Pablo Martinez

Pablo Martinez

  • 2,468 Points 2k badge 2x thumb
Yes, right now I'm testing it with my account. and I can see and edit the gps coords fields.

What Im thinking it's maybe this is not working because is in other object? I mean, I'm querying Opportunity_Sales_Item__c but the condition is on Site__r.GpsCoords__c 
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Pablo,

I have tried to replicate a similar scenario with standard objects and fields, and the Condition's SOQL is being generated correctly and the query is running as expected. I am using the Account BillingAddress field and the Contact MailingAddress field, both of which are treated as Geolocations. I have 2 Models and here are the Conditions:





What Skuid version are you running?
Photo of Zach Gray

Zach Gray

  • 30 Points
Pablo, did you have any luck with this? I'm experiencing what appears to be the same issue. I've found if I use in my filter field an ADDRESS field (these are only on standard objects) that it works just fine. If I try to use the GeoLocation field though, it doesn't work. I get the same result on the query in your example where the soql filter doesn't show up.

In other words, Account.ShippingAddress works, but CustomObject.Address_Geolocation__c does not.
Photo of Brayden Smith

Brayden Smith

  • 1,078 Points 1k badge 2x thumb
I'm experiencing the same issue. The condition is not added to the SOQL query when using custom fields on a custom object.
(Edited)
Photo of Zach Gray

Zach Gray

  • 30 Points
Brayden, I found that I could utilize the REST SOQL API to get around the issue. I set up 'external data' using this method: http://help.skuid.com/m/models-conditions-filters/l/530859-connecting-to-external-data-in-skuid

That external data just happened to be the Salesforce REST API. 

This wasn't the best, but it worked.