/
Handling Custom Picklists
Handling Custom Picklists
Values for custom Pick-list fields in Salesforce can be set as strings. The following example is for a built-in field, but the same approach will work for custom fields.
For the Account Rating picklist field the value can be set as follows:
/// <summary> /// Manually created enum to represent known picklist values /// </summary> public enum AccountRatings { Cold, Warm, Hot } [TestMethod] public void UpdatePicklistField() { SalesforceSession salesforceSession = SessionTest.GetActiveSession(); AccountService accountService = new AccountService(salesforceSession); // Retrieve an existing Account. Just get the required fields. Id existingAccountId = (Id)"00190000002G9cF"; Account account = accountService.GetByEntityId(existingAccountId, nmew SObjectField[] { Account.Fields.Id, Account.Fields.Rating}); string existingRating = account.InternalFields["Rating"]; // Example using internal fields to set a picklist value. // Would equally work for custom picklist fields. // account.InternalFields["Rating"] = "Hot"; account.InternalFields["Rating"] = AccountRatings.Cold.ToString(); SaveResult updateResult = accountService.UpdateEntity(account); Assert.IsTrue(updateResult.success); // Restore previous value using the generated property. account.Rating = existingRating; accountService.UpdateEntity(account); }
, multiple selections available,
Related content
Multi select picklists
Multi select picklists
More like this
Retrieving Picklist Values
Retrieving Picklist Values
More like this
Retrieving Multipicklist Field Values
Retrieving Multipicklist Field Values
More like this
Accessing Custom Objects and Custom Fields
Accessing Custom Objects and Custom Fields
More like this
Custom Form Controls - Save to Salesforce
Custom Form Controls - Save to Salesforce
More like this
Custom Form Validator
Custom Form Validator
More like this