[SalesForce] Using Task Record Type via REST API

We have a number of picklists that are subsetted via task record types.
I can pull these record type via a simple SOQL query:

SELECT Name, DeveloperName FROM RecordType WHERE SobjectType = 'Task'

To make this useful, via API how can I:

  1. Tell which record type has which values?
  2. Identify the task record type for a user?
    I think this can be done via Page Layouts but it's not clear how

  3. Set the record type when creating a task?
    I think this is not needed as the layout handles the assignment

Best Answer

  1. The picklist-values-per-record-type issue is an old problem to which there's only recently a semi-decent solution. There's a number of ways to approach this, and if you're already using the API, the new UI API is probably the best way to go.
  2. You can use a variety of routes to access record type availability. Issuing a Describe API call to, e.g., /services/data/v43.0/sobjects/Opportunity/describe has keys available (for the running user's Profile) and defaultRecordTypeMappingunder each of the entries in the recordTypeInfos. The Metadata API also permits you to get record type availability and default record type information at the Profile level, but it's non-trivial. The Tooling API can theoretically also yield this information, although I wasn't immediately able to get the record type visibilities that way in Workbench. (Looks like others have had that issue too).
  3. This is the easiest, but it has nothing to do with the page layout. Just set the field RecordTypeId on the Task you're inserting to the Id of the desired record type.

Note that if the Profile has exactly one custom record type associated with it, that will be used automatically.

Related Topic