function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ccPeterccPeter 

List the custom input fields in a particular Content Type

When doing a "Describe" on ContentVersion, all custom input fields (xxx__c) defined for all Content Types are included in the result. When putting up an input form, in the case where a Library only has a particular Content Type attached, how do restrict the custom input fields to only the ones defined in the Content Type(s) attached to the Library?

 

Another way of asking the same question is, how do you use the REST API to enumerate the custom fields defined for a particular Content Type?

 

Thanks
Peter

Best Answer chosen by Admin (Salesforce Developers) 
ccPeterccPeter

Thanks for pointing me in the right direction, Simon. Once I realized a Content Type is also a Page Layout things fell into place. I was also able to make the SOAP calls and still keep my REST-based code intact. I am all set now.

 

Peter

All Answers

SuperfellSuperfell

Fields aren't associated with a recordType, there are fields in a layout (and there is a mpping of recordtypes -> layouts by profile), there is a describeLayout call that returns information about a particular page layout (which could be ascoicated with a particular recordType), but this function is only available in the soap api, not the rest api.

ccPeterccPeter

Thanks, Simon. If only the ContentVersion/Describe would, in each custom field, include an array of RecordTypeIds to refer to the Content Types containing these custom fields... That is really all I am looking for.


Is there any way I could request the relationship between custom input fields and Content Types to be added to ContentVersion/Describe in the next release?


With respect to a potential workaround with describeLayout in the SOAP API, wouldn’t this require that the Salesforce user/administrator create pages that refer to these custom fields? In other words, is the workaround guaranteed to work in all cases? I have not had a chance to explore this aspect of Salesforce yet, that is why I am asking.

 

Also, could both SOAP and REST be used in the same application i.e. could the access_token and instance_url obtained with REST be used with SOAP, or would I have to redo everything I did up to now with REST and replaced it with SOAP (a move I would rather not make since I think this REST API is really intuitive and easy to use).


Thanks
Peter

SuperfellSuperfell

You can mix and match soap & rest requests from a single app that's not a problem.

 

You can log feature requests on the idea exchange, although I still think you missunderstand the relationship between fields / recordTypes & layouts.

ccPeterccPeter

Thanks, Simon. Exactly, you are right, I don't feel I have a handle on the relationship between fields / recordTypes & layouts. Could you please point me to a piece of documentation that could improve my understanding and get me over this hurdle?

 

I read the describeLayout in the Web Services API Developer's Guide; however, the nature of that write-up is more reference material that does not provide an overview.

 

Thanks

Peter

SuperfellSuperfell

I'd start by reading the online help for record types, that should get you upto speed.

ccPeterccPeter

Thanks for pointing me in the right direction, Simon. Once I realized a Content Type is also a Page Layout things fell into place. I was also able to make the SOAP calls and still keep my REST-based code intact. I am all set now.

 

Peter

This was selected as the best answer
audipenaudipen

Hi Peter,

 

I need to achieve exactly what you had asked - obtain the list of custom fields for a Content library. I did go through the thread and read about RecordType but the confusion still exists. Now I am confused about the relation between RecordType and Content type. Are they the same> If not , how are they different.

 

Also were you able to obtain the list of custom fields for a content library?