1

My org has two RecordTypes on the Event object. There is a custom field of type picklist that uses different picklist values depending on which record type is selected. I need to fetch a list of values for this field for a specific record type through the API.

How can I do this with the REST API?

So far the only way I've found is to call the describe function with the record ID:

/services/data/vXXX/sobjects/Event/describe/layouts/{recordId}

However this requires a separate call to lookup the appropriate record ID as this can vary between sandbox and production.

Is it possible to get the picklist values (filtered by record type) with one API call?

0

At minimum, you need two describe calls no matter how you look at it. It's worth noting that your app should cache the results for performance reasons, since metadata rarely changes (see also the If-Modified-Since header).

I would suggest /ui-api/record-api/{record-id} to get all the data and layout metadata, followed by /ui-api/object-info/{objectApiName}/picklist-values/{recordTypeId} to get all the picklist values you need.

| improve this answer | |
  • I was able to get the info I needed with one API call using the metadata API. I suppose my question was too specific regarding the use of REST api. – user85715 Jul 27 at 22:46
0

Sharing my result as I wasn't able to find much on this subject.

I was able to get the information I needed with one metadata API call:

metadata.read({
    metadataType: 'CustomObject',
    fullNames: [ 'Event' ]
});

this returned exactly what I was looking for, which was distinct picklist value sets for each record type.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.