Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Current »

This code block shows how to get a list of all the Salesforce Objects that are available to the user through the API. The objects are returned as a list of string values representing the API name of the object:

SalesforceSession salesforceSession = new SalesforceSession(new LoginDetails("username@example.com", "salesforcePassword"));

IList<String> salesforceObjects = session.SObjectApiNames();

foreach (String sObject in salesforceObjects)
{
  Console.WriteLine(sObject);
}

This code block shows how to get all of the fields for a given Salesforce Object name:

SalesforceSession salesforceSession = new SalesforceSession(new LoginDetails("username@example.com", "salesforcePassword"));

//specify the API name of the Salesforce Object
String salesforceObject = "My_Custom_Object__c";

FieldService fieldService = FieldService.Instance(salesforceObject, salesforceSession);

List<SalesforceField> fields = fieldService.FieldsForObject();

//output some field metadata
foreach (SalesforceField field in fields)
{
  Console.WriteLine(field.label + ": " + field.name);
  Console.WriteLine("Field Type: " + field.type);
}

If changes are made to a Salesforce Object while an S4S Salesforce Session is zzz, then you will need to clear the session binding cache for the session user:

//retrieve a current Salesforce Session Singleton
SalesforceSession salesforceSession = GetSalesforceSessionSingleton();

salesforceSession.Binding.ClearCacheForUser(SFSession.SalesforceUserId);

  • No labels