A few weeks ago, in this post, I explained how to embed Google Maps on RightNow CX, in order to quickly see the Contacts’s address using the information in the RightNow database.
Some of you asked if this was possible to do with Organisations. The answer was: unfortunately it is not as straight forward as with Contact, and there is two reasons for that:
a) The Address field in Organisation – “Oaddr” – is different than that in the Contact. It is a collection of addresses that has two types: Billing and Shipping. These are controlled by objects “Organization Addresses” and “Organization Address Types”.
b) Address values in Organisation are not available to get directly. “Oaddr” is expressed as string XML data of the following form:
<Addr Street=”123 main st” City=”Bozeman” ProvId=”23″ PostalCode=”59718″ CountryId=”1″ />.
- Get and parse the Organisation address
- Retrieve the values (Street, City, Province, Postal Code, Country)
- Build a Google Maps URL with the values
- Navigate to Google Maps using “window.location”
The solution is then:
//0 for billing addr and 1 for shipping addr
var address = window.external.Org.OAddresses;
//Parsing the XML into object
var xmlDoc = new ActiveXObject(“Microsoft.XMLDOM”);
xmlDoc.async = “false”;
//Retrieving all the fields of selected Organisation Address
//Fetching Province Name corresponding to provinceID retrieved
var provLabels = org.GetNameValues(“ProvId”);
for (i = 0; i < x.length; i++)
//Fetching Country Name corresponding to countryId retrieved
var countryLabels = org.GetNameValues(“CountryId”);
for (i = 0; i < y.length; i++)
//Building the google maps URL
var finalAddress=street+” “+city+” “+postalCode+” “+ provinceName+” “+countryName;
- Step 2: Upload the HTML file to a server via FTP (I normally use FileZilla).
- Step 3: Add a new tab to the Organisations Workspace and drag and drop a browser control into the tab
- Step 5: Select the browser control, go to the Design tab > Options section, and put the URL path of the HTML file into the URL field.
- Step 6: Select the browser control, go to the Design tab > Options section, and un-check the Delay Page Load check box.
Now, whenever you open an Organisation, and navigate to the “Map” tab, you will automatically see the Organisations’s address on the map.
6 thoughts on “Google Maps for Organisations”
Superb Luis! Bhagwan is a champ! 🙂
Hi Bhagwan, I’m not sure you should upload this to the Service Cloud CP folders via cyberduck. You should put it on an FTP server.
Can you upload it as a file attachment into Service Cloud and copy the URL here. Doesn’t seem to work when I tried it. This code was generated in 2013, so I wonder if some of the schema names have changed in the last 2 years, and therefore the code needs re-writing. any thoughts?
I have the file uploaded into my personal website, and therefore didn’t want to share it publicly. I will send you an email with the code I’m using.
Great solution! I am definitely going to use it.
I know that this question doesn’t relate to this post, but is related to JS API.