I used to use fql to get latitude and longitude from Place.
How do I do it nowadays? I've got the user's location, but only id and name are filled in. Everything else is null. Code:
FacebookClient fc = new DefaultFacebookClient(token, Version.VERSION_2_9);
User user = fc.fetchObject("me", User.class, Parameter.with("location"));
Location loc = fc.fetchObject(user.getLocation().getId(), Location.class);
Also tried:
Place pl = fc.fetchObject(user.getLocation().getId(), Place.class);
Same thing.
As I wrote in the RestFB bugtracker:
FacebookClient fc = new DefaultFacebookClient(token, Version.VERSION_2_9);
User user = fc.fetchObject("me", User.class, Parameter.with("fields","location"));
Page pageOfUserLocation = fc.fetchObject(user.getLocation().getId(),
Page.class, Parameter.with("fields","location");
if (pageOfUserLocation.getLocation() != null) {
System.out.println("longitude: ", pageOfUserLocation.getLocation().getLongitude());
System.out.println("latitude: ", pageOfUserLocation.getLocation().getLatitude());
}
Related
Im trying to get my current latitude and longitude values using LocationManager in Codename One but the values i'm getting is for a different location.
Here is my code:
LocationManager locationManager = LocationManager.getLocationManager();
Location location = locationManager.getCurrentLocation();
Double loc1= location.getLatitude();
Double loc2= location.getLongitude();
System.out.println("Latitude: "+loc1);
System.out.println("Longitude: "+loc2);
Output:
Latitude: 40.715353
Longitude: -74.00497299999999
My correct current Latitude and Longitude values are 3.xxxx and 101.xxxx respectively.
Please how can I get these correct values from LocationManager?
That is default location on Simulator.
Note that you can't get your actual location on Simulator without entering it yourself.
To set your simulator to use your current location, Click Simulate on your simulator and select Location Simulation. Enter your LatLong values for Available and Click Update. The Google map will shift view to your location, So would your app.
You can keep Location Simulator open while you test your app.
On a side note, if your app needs a real time location I would suggest you use getCurrentLocationAsync(). Below is an example:
InfiniteProgress ip = new InfiniteProgress();
Dialog ipDlg = ip.showInifiniteBlocking();
Location location = LocationManager.getLocationManager().getCurrentLocationSync(30000);
ipDlg.dispose();
if (location == null) {
try {
location = LocationManager.getLocationManager().getCurrentLocation();
} catch (IOException err) {
Dialog.show("Location Error", "Unable to find your current location, please be sure that your GPS is turned on", "OK", null);
return;
}
}
Double loc1 = location.getLatitude();
Double loc2 = location.getLongitude();
Log.p("Latitude: " + loc1);
Log.p("Longitude: " + loc2);
I have a trigger that moves the values from one object to another, but am stuck on how to move the values of the lookup fields from one to the other. what is the syntax? If you could show me the Company and the Chair_Rep ones that would be great!
<Lead> newLeadsList= new List<Lead>();
for (integer i=0; i<newContacts.size(); i++) {
if (newContacts[i].createlead__c == TRUE && oldContacts[i].createlead__c == FALSE ) {
newLeadsList.add(new Lead(
firstName = newContacts[i].firstName,
lastName = newContacts[i].lastName,
***Company = newContacts[i].account.name,***
Status = 'identified',
LeadSource = newContacts[i].leadsource ,
Product_Interest__c = 'CE',
//ContactLink__c = newContacts[i].ID,
Title = newContacts[i].title,
Email = newContacts[i].email,
//***Chair_Rep__c = newContacts[i].Chair_Rep__c***
Phone = newContacts[i].Phone,
MobilePhone = newContacts[i].MobilePhone,
// Address = newContacts[i].MailingAddress,
//Website = newContacts[i].Website,
nickname__c = newContacts[i].Nickname__c
Lookup fields should contain references (IDs) on records.
Is 'Company' a standard Lead field in your code?
***Company = newContacts[i].account.name,***
If so, then it's a Text(255) type field, which cannot be used as lookup.
If you need to make a lookup on a Contact's account record, then you can create a custom Lookup field on Lead with reference to Account. And then you could try this code (assuming ContactCompany is that custom lookup field :
ContactCompany__c = newContacts[i].AccountId
or
ContactCompany__c = newContacts[i].Account.Id
Chair_Rep__c and newContacts.Chair_Rep__c should be lookup fields on same object. Then this
Chair_Rep__c = newContacts[i].Chair_Rep__c
or this should work
Chair_Rep__c = newContacts[i].Chair_Rep__r.Id
I'm trying the recover the location of a card previously set, so I could replace the HTML card with a map and a route with Glass last location.
But when I get the card back, it has no location. The location is set on card because I tested on Glass and it's all right.
Here's my piece of PHP code:
elseif ($user_action['type'] == 'CUSTOM' && $user_action['payload'] == 'show-in-map')
{
$timeline_item_id = $request['itemId'];
$timeline_item = $mirror_service->timeline->get($timeline_item_id);
$patch = new Google_TimelineItem();
$cardFomater = new Card_Formater($patch->getHtml());
$cardLocation = $timeline_item->getLocation();
$patch->setHtml($cardFomater->replaceHtmlWithMap($location->getLatitude(),$location->getLongitude(),
$cardLocation->getLatitude(),$cardLocation->getLongitude()));
$mirror_service->timeline->patch($timeline_item_id, $patch);
}
It says the $cardLocation does not have the property getLatitude().
I am trying to determine a way to audit which records a given user can see by;
Object Type
Record Type
Count of records
Ideally would also be able to see which fields for each object/record type the user can see.
We will need to repeat this often and for different users and in different orgs, so would like to avoid manually determining this.
My first thought was to create an app using the partner WSDL, but would like to ask if there are any easier approaches or perhaps existing solutions.
Thanks all
I think that you can follow the documentation to solve it, using a query similar to this one:
SELECT RecordId
FROM UserRecordAccess
WHERE UserId = [single ID]
AND RecordId = [single ID] //or Record IN [list of IDs]
AND HasReadAccess = true
The following query returns the records for which a queried user has
read access to.
In addition, you should add limit 1 and get from record metadata the object type,record type, and so on.
I ended up using the below (C# using the Partner WSDL) to get an idea of what kinds of objects the user had visibility into.
Just a quick'n'dirty utility for my own use (read - not prod code);
var service = new SforceService();
var result = service.login("UserName", "Password");
service.Url = result.serverUrl;
service.SessionHeaderValue = new SessionHeader { sessionId = result.sessionId };
var queryResult = service.describeGlobal();
int total = queryResult.sobjects.Count();
int batcheSize = 100;
var batches = Math.Ceiling(total / (double)batcheSize);
using (var output = new StreamWriter(#"C:\test\sfdcAccess.txt", false))
{
for (int batch = 0; batch < batches; batch++)
{
var toQuery =
queryResult.sobjects.Skip(batch * batcheSize).Take(batcheSize).Select(x => x.name).ToArray();
var batchResult = service.describeSObjects(toQuery);
foreach (var x in batchResult)
{
if (!x.queryable)
{
Console.WriteLine("{0} is not queryable", x.name);
continue;
}
var test = service.query(string.Format("SELECT Id FROM {0} limit 100", x.name));
if(test == null || test.records == null)
{
Console.WriteLine("{0}:null records", x.name);
continue;
}
foreach (var record in test.records)
{
output.WriteLine("{0}\t{1}",x.name, record.Id);
}
Console.WriteLine("{0}:\t{1} records(0)", x.name, test.size);
}
}
output.Flush();
}
I been trying to get sqlcachedependecy working, but it doesn't appear to work
I got the proper settings in my web.config and also global.asa, however when I run this query and the changes are made to the database from either with in or outside the web site the cached objects are not updated please someone help? I know its not because this query is querying a view, because I tested this using straight SqlDependecy and the notification works fine.
public IQueryable<VictoryList> GetVictoryList()
{
string cacheKey = HttpContext.Current.User.Identity.Name + "victoryCacheKey";
IQueryable<VictoryList> cachednews = (IQueryable<VictoryList>)HttpContext.Current.Cache.Get(cacheKey);
if (cachednews == null)
{
var results = from v in _datacontext.ViewVictoryLists
orderby _datacontext.GetNewId()
select new VictoryList
{
MemberID = v.MemberID,
Username = v.Aspnetusername,
Location = v.Location,
DaimokuGoal = v.DaimokuGoal,
PreviewImageID = v.PreviewImageID,
TotalDaimoku = v.TotalDaimoku,
TotalDeterminations = v.TotalDeterminations,
DeterminationID = v.DeterminationID,
DeterminationName = v.DeterminationName
};
results = results.ToList().AsQueryable();
SqlCacheDependencyAdmin.EnableNotifications(_datacontext.Connection.ConnectionString);
SqlCacheDependency dependency =
new SqlCacheDependency(_datacontext.GetCommand(results) as SqlCommand);
HttpContext.Current.Cache.Insert(cacheKey, results, dependency);
return results;
}
return cachednews;
}
According to the stated Limitations for creating a query for notification, listed at msdn...
The statement must not reference a view.