5

I'm trying to retrieve a list of all record types relating to the Contact object in Salesforce using the Enterprise WSDl in C#. Currently I am setting a Contact object like this:

var contact = new Contact();
contact.Email = user.Email.
contact.FirstName = user.FirstName;
etc ...

The Contact object has a RecordType property but I need to retrieve all of the record types first in order to assign the correct object.

Currently I cannot find a way of doing this. At first I thought RecordTypeMapping would allow me to do this but it seems to be a middle object between something that could retrieve record types.

How can I retrieve a list of all record types for Contact?

2 Answers 2

4

You can query the RecordType object:

select Id, Name, Description, DeveloperName, IsActive from RecordType
where sobjecttype='Contact'

This will give you all the possible values for the recordtypeid

2
  • Thanks for your answer. Once I retrieve this result is it just a matter of creating a new RecordType object setting the properties to the values returned?
    – Serberuss
    Jun 17, 2013 at 15:14
  • You use the ID value that you have retrieved from the query on RecordType as the value to insert into contact.recordtypeid. For example contact.recordtypeid = [select id from recordtype where sobjecttype='Contact' and developername='Supplier']; (although you probably want to query the recordtype and cache results, but this should give you the idea)
    – Doug B
    Jun 17, 2013 at 15:21
2

You can query the RecordType table. A sample SOQL query would be:

SELECT DeveloperName,Name FROM RecordType WHERE SObjectType = 'Contact'

You might also be able to do this with a describe call.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .