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
AmiableAmiable 

this.id returns nothing

After much massaging, I finally got the Google map code to work except for one thing!  When the map displays my leads (or contacts), I cannot drill down into the balloon name as expected.  It appears that "this.id" is returning nothing preventing me from properly forming the link.

Any ideas?

DevAngelDevAngel
Hi Amiable,

Post a little of you code (enough for me to figure out what you are doing). "this" can be a bit difficult in javascript as it's meaning changes depending on when the and by what the function was called by/from.
AmiableAmiable


DevAngel wrote:
Hi Amiable,

Post a little of you code (enough for me to figure out what you are doing). "this" can be a bit difficult in javascript as it's meaning changes depending on when the and by what the function was called by/from.




This only occurs when you try to click on the name in a pop-up from google maps. If you mouse over the hyperlinked name you see "https://ssl.salesforce.com", which takes you right back to a login. It is supposed to take you to that contact in sf.

The area that I think is causing the problem in the sample google maps code is below. It does not appear to accept anything after the beginning of the link above and will take you back to a login prompt effectively throwing you out of SF.

Thanks for your help!!!



AddressObject.prototype.makeHtml = function() {
var html = "
";
//*****problem here?*************************************************

html += "" + this.name.replace("&", " ") + "
";

//*******************************************************************
if (this.sObject.getName().toLowerCase() == "lead") {


html += "" + this.sObject.get("id") + "
";


html += "" + this.title + "
";
html += "" + this.sObject.get("company") + "
";
} else if (this.sObject.getName().toLowerCase() == "contact") {
html += "" + this.title + "
";
if (this.accountName != null) {
html += "" + this.accountName + "
";
}
} else if (this.sObject.getName().toLowerCase() == "account") {
if (this.acctType != null && this.acctType != "") html += "Type: " + this.acctType + "
";
if (this.numberofemployees != null && this.numberofemployees != "") html += "Employees: " + this.numberofemployees + "
";
}
if (map.sfield != undefined) {
var critField = map.sfield;
var critFieldLabel = this.sObject.getDefinition().fieldMap[critField.toLowerCase()].label;
if (this.sObject.contains(map.sfield)) {
if (this.sObject.get(critField) != null && this.sObject.get(critField).lenght > 0) {
html += "
" + critFieldLabel + ": " + this.sObject.get(critField) + "

";
}
}
}

var phoneHtml = "";
if (this.phones.length > 0) {
phoneHtml += "";
var showPhoneData = false;
for (var i=0;i if (this.phones[i].phoneType.toLowerCase() != "fax") {
html += this.phones[i].phoneType + ": " + this.phones[i].phoneNumber + "
";
showPhoneData = true;
}
}
if (showPhoneData == true) {
html += "
" + phoneHtml;
}
}
if (this.sObject.getName().toLowerCase() == "lead" || this.sObject.getName().toLowerCase() == "contact") {
if (this.sObject.get("email") != null && this.sObject.get("email") != "") {
html += "Email: " + this.sObject.get("email") + "

";
}
}
html += "" + this.getStreet() + "
" + this.getCity() + ", " + this.getState() + "
";
if (this.website != null && this.website != "") {
html += "" + this.website + "
";
}
html += "
";
return html;
}
AmiableAmiable
Arghhh....The submit button butchered my code paste. I'll try again with only the releveant line.....

"html += "" + this.name.replace("&", " ") + "
";"
AmiableAmiable
Can't seem to paste the code beacuase it keeps getting interpreted. One last try.......


If this does not work, you can find this code in the google maps example around line 522. I did some edits so line numbers may be a bit off. You can also search on "ssl.salesforce.com" and go right to the line I think is causing the problem.


href='https://ssl.salesforce.com/" + this.id + "' target=''>" + this.name.replace("&", " ") + "
";
DevAngelDevAngel

In context, this is referring to the AddressObject. When an address object is created it takes a parameter called sObject which contains the record from the query result record array and the "this.id" field is set using sObject.get("Id"). Now, if some other field is returning null it might be munging up the href being generated, so a missing Id may not be the problem. The best thing to do would be to spit out the sObject to the debug window by adding the third line shown below to the makeHtml function.

. AddressObject.prototype.makeHtml = function() { var html = "<div>"; txtSoqlSosl.value += "\n\nSOBJECT = " + this.sObject.toString(); var host = document.location.href; host = host.substring(0, host.indexOf(".com/") + 5);

You also need to make sure to toggle the diagnostics flag by changing the assignment from "off" to "on".

1057 var diagnostics = "off"; 1058 var btnShowDiagnostics; 1059 var showFindArea = false; 1060 var defaultObject = "account"; 1061 var queryOnLoad = true; 1062 1063 function initializeMap() {

AmiableAmiable
I added the code and turned on diag. It nows displays all of the sobject info in the diag window but I am not sure what I am looking for. AN example is below;

SOBJECT = Lead
Id =
LastName = Digac
FirstName = Shelly
Street = PO Box 954
City = Lakeland
State = Florida
PostalCode = 33804
Company = Lakeland Regional Medical Center
Title = Director of Data Processing/Management Information Systems
Website = http://www.lrmc.com
Email = sdigac@123.com
lat__c = 28.043333
lon__c = -81.956667
Phone = +1.863.687.1212
MobilePhone =
Fax =
Asst_Phone__c =
CreatedDate = Wed Nov 9 08:47:18 CST 2005

lat diff: 14.932165000000001, max is 42.975498
lon diff: -11.066097999999996, max is -81.956667


The only thing I notice is that "Id" is blank as it is for all of the listings. I also noticed that you example appears to be different. Was I supposed to add the lines after the sobject line as well? The var host line does not exist in my version.
DevAngelDevAngel
You should check the SOQL statements then. There are 3 partial soql statements, I think near the top of the file. Make sure the id is in the select list.
AmiableAmiable


DevAngel wrote:
You should check the SOQL statements then. There are 3 partial soql statements, I think near the top of the file. Make sure the id is in the select list.




Tha makes sense! I pulled the "accountid" out of that select statement because it caused the entire query to fail. I tried to use "leadid" but that fails as well. How can I see what the "id" field is actually called for a lead, or any other query for that matter? I tried looking at the "fields" in customize section but that seems to be limited to fields you can customize.

Forgive my ignorance but I am used to being able to look at the actual db structure to figure these things out. SalesForce is a bit of a different animal and I have not been able to attend develpoer training.

Thanks again for your help!
DevAngelDevAngel
Hi Amiable,
 
I highly recommend downloading and installing the sforce explorer.  It gives you a nice tree-view of the entire object schema including field names and field labels.