extract Event Address

I need to extract the address of events from using the web service api.

Basically, I need to get all events tied to today's date and extract their addresses. (I realize some may not have addresses and I would filter for that).

C# or VB.NET example would be fine.
Who is Participating?
crandeljConnect With a Mentor Author Commented:
Thanks for your feedback.  What I was looking for was the address associated with the Contact/Lead associated with the event.  Of course there are multiple addresses associated with these objects so we had to standardize on one (we chose shipping for our purposes).  

It wasn't that tough once I figured out which WSDL to use. You just look at the event object, find the whoID of the contact/lead and then query that object to find the address.

Have you tried any of the developer services at  Here is a link:
When you say "Address", do you mean the Location field on Event?  If so, here's the SOQL query you'll need to retrieve the records you need.

SELECT Id, Location FROM Event WHERE ActivityDate=Today AND Location!=Null

You can certainly select more fields than just Id and Location, depending on your need.

How you actually make a call in the language of your choosing, be it C#, VB.NET, or Java, is really too long a topic to discuss here.  Check out the Web Services API Developer's Guide from SFDC.  Here's a piece of sample code from there (assuming you've done the WSDL importing, etc.):

using System;
using System.Collections
using System.Text;
using System.Web.Services.Protocols;
using Walkthrough.sforce;
namespace Walkthrough
class WalkthroughSample
private SforceService binding;
static private WalkthroughSample walkthroughSample;
static void Main(string[] args)
walkthroughSample = new WalkthroughSample();;
public void run()
//Call the login call
if (login())
//Do a describe global
//describe an account object
//retrieve some data using query
private bool login()
Console.Write("Enter username: ");
string username = Console.ReadLine();
Console.Write("Enter password: ");
string password = Console.ReadLine();
// Create a service object
binding = new SforceService();
// Timeout after a minute
binding.Timeout = 60000;
// Try logging in
LoginResult lr;
Console.WriteLine("LOGGING IN NOW...");
lr = binding.login(username, password);
// ApiFault is a proxy stub generated from the WSDL contract when
// the web service was imported
catch (SoapException e)
// Write the fault code to the console
// Write the fault message to the console
Console.WriteLine("An unexpected error has occurred: " + e.Message);
// Write the stack trace to the console
// Return False to indicate that the login was not successful
return false;
// Check if the password has expired
if (lr.passwordExpired)
Console.WriteLine("An error has occurred. Your password has expired.");
return false;
/** Once the client application has logged in successfully, it will use
* the results of the login call to reset the endpoint of the service
* to the virtual server instance that is servicing your organization
binding.Url = lr.serverUrl;
/** The sample client application now has an instance of the SforceService
* that is pointing to the correct endpoint. Next, the sample client
* application sets a persistent SOAP header (to be included on all
* subsequent calls that are made with SforceService) that contains the
* valid sessionId for our login credentials. To do this, the sample
* client application creates a new SessionHeader object and persist it to
* the SforceService. Add the session ID returned from the login to the
* session header
binding.SessionHeaderValue = new SessionHeader();
binding.SessionHeaderValue.sessionId = lr.sessionId;
// Return true to indicate that we are logged in, pointed
// at the right URL and have our security token in place.
return true;
private void describeGlobal()
//describeGlobal returns an array of object results that
//includes the object names that are available to the logged-in user
DescribeGlobalResult dgr = binding.describeGlobal();
Console.WriteLine("\nDescribe Global Results:\n");
//Loop through the array echoing the object names to the console
for (int i = 0; i < dgr.sobjects.Length; i++)
Console.WriteLine("\n\nHit enter to continue...");
private void describeSObject(string objectType)
//Call the describeSObject passing in the object type name
DescribeSObjectResult dsr =
//The first properites we will echo are on the object itself
//First we will output some Descriptive info on the object
Console.WriteLine("\n\nObject Name: " +;
if (dsr.custom) Console.WriteLine("Custom Object");
if (dsr.label != null) Console.WriteLine("Label: " + dsr.label);
//now the permissions on the object
if (dsr.activateable) Console.WriteLine("Activateable");
if (dsr.createable) Console.WriteLine("Createable");
if (dsr.deletable) Console.WriteLine("Deleteable");
if (dsr.queryable) Console.WriteLine("Queryable");
if (dsr.replicateable) Console.WriteLine("Replicateable");
if (dsr.retrieveable) Console.WriteLine("Retrieveable");
if (dsr.searchable) Console.WriteLine("Searchable");
if (dsr.undeletable) Console.WriteLine("Undeleteable");
if (dsr.updateable) Console.WriteLine("Updateable");
//Now we will retrieve meta-data about each of the fields
for (int i = 0; i < dsr.fields.Length; i++)
//Create field object for readability
Field field = dsr.fields[i];
//Echo some useful information
Console.WriteLine("Field name: " +;
Console.WriteLine("\tField Label: " + field.label);
//This next property indicates that this
//field is searched when using
//the name search group in SOSL
if (field.nameField)
Console.WriteLine("\tThis is a name field.");
if (field.restrictedPicklist)
Console.WriteLine("This is a RESTRICTED picklist field.");
Console.WriteLine("\tType is: " + field.type.ToString());
if (field.length > 0)
Console.WriteLine("\tLength: " + field.length);
if (field.scale > 0)
Console.WriteLine("\tScale: " + field.scale);
if (field.precision > 0)
Console.WriteLine("\tPrecision: " + field.precision);
if (field.digits > 0)
Console.WriteLine("\tDigits: " + field.digits);
if (field.custom)
Console.WriteLine("\tThis is a custom field.");
//Output the permission on this field.
if (field.nillable) Console.WriteLine("\tCan be nulled.");
if (field.createable) Console.WriteLine("\tCreateable");
if (field.filterable) Console.WriteLine("\tFilterable");
if (field.updateable) Console.WriteLine("\tUpdateable");
//If this is a picklist field, we will show the values
if (field.type.Equals(fieldType.picklist))
Console.WriteLine("\tPicklist Values");
for (int j = 0; j < field.picklistValues.Length; j++)
Console.WriteLine("\t\t" + field.picklistValues[j].value);
//If this is a foreign key field (reference),
//we will show the values
if (field.type.Equals(fieldType.reference))
Console.WriteLine("\tCan reference these objects:");
for (int j = 0; j < field.referenceTo.Length; j++)
Console.WriteLine("\t\t" + field.referenceTo[j]);
Console.WriteLine("\n\nHit enter to continue...");
private void querySample()
//The results will be placed in qr
QueryResult qr = null;
//We are going to increase our return batch size to 250 items
//Setting is a recommendation only, different batch sizes may
//be returned depending on data, to keep performance optimized.
binding.QueryOptionsValue = new QueryOptions();
binding.QueryOptionsValue.batchSize = 250;
binding.QueryOptionsValue.batchSizeSpecified = true;
qr = binding.query("select FirstName, LastName from Contact");
bool done = false;
if (qr.size > 0)
Console.WriteLine("Logged-in user can see "
+ qr.records.Length + " contact records.");
while (!done)
for (int i = 0; i < qr.records.Length; i++)
Contact con = (Contact)qr.records[i];
string fName = con.FirstName;
string lName = con.LastName;
if (fName == null)
Console.WriteLine("Contact " + (i + 1) + ": " + lName);
Console.WriteLine("Contact " + (i + 1) + ": " + fName
+ " " + lName);
if (qr.done)
done = true;
qr = binding.queryMore(qr.queryLocator);
Console.WriteLine("No records found.");
catch (Exception ex)
Console.WriteLine("\nFailed to execute query succesfully," +
"error message was: \n{0}", ex.Message);
Console.WriteLine("\n\nHit enter to exit...");

Open in new window

Should be a good start to adapt it for your own use.
crandeljAuthor Commented:
I solved this one myself so I hope this is the way to close it properly.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.