function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Pradeep JonnalagaddaPradeep Jonnalagadda 

Data Integration Rules

Hi Everyone, 
I have enabled Data Integration Rules on Leads to get the Geo location (Latitude and longitude). Basically, when I create a lead with a valid
address it populates the latitude and longitude. In the code, I'm trying to copy the lat&long to my custom object by performing SOQL right after
the insert. I get null values for lat and long on SOQL but when the program exits the very same SOQL has valid values. It has to do with the order of execution I guess of data integration rules I suppose. I tried to split the functionality by doing the insert on lead in one program followed by SOQL in the after insert trigger of Lead. The trigger code is getting executed with same null values for latitude and longitude. 


Below is my code all in one program:

Lead lead= new Lead(LastName='Johnson',Company='Salesforce', Street='The Landmark @ One Market', City='San Francisco',State='California',postalCode='94105');

insert lead;

Lead thisLead= [select latitude, longitude,city,state,street from Lead];
System.debug('thlead='+thisLead.latitude);//null value 

Any insights appreciated?
Langning Chen 7Langning Chen 7
The query returns if you add ID or Name field to your SOQL statement.

select id, name, latitude, longitude,city,state,street from Lead