/
Working with Salesforce Metadata
Working with Salesforce Metadata
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 already established, 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); |
Related content
Constructors
Constructors
More like this
Accessing Custom Objects and Custom Fields
Accessing Custom Objects and Custom Fields
More like this
Methods
Methods
More like this
Get Salesforce Entity
Get Salesforce Entity
More like this
Working with the SalesforceGenericEntity
Working with the SalesforceGenericEntity
More like this
Retrieving Picklist Values
Retrieving Picklist Values
More like this