0

I have a list - Documents (Actually document library). I have given it two types of content types :- Document(default) & MyDocumentContentType (this is my custom content type)

Now Content Type Document have Title as Required field. And Content Type MyDocument have a custom col as required field - "MyRequiredField"

Now I want to fetch all the fields for list Documents, which have required property merged from all the content types.

Currently -> I get only Title as Required Field.

I want -> Title and MyRequiredField both as Required Fields.

I know I can fetch Fields for perticular content type by using ..../ContentTypes(ID)/Fields.

But it will give me fields for that particular content type.

Currently I have only option is to iterate over all the content types associated with a list and fetch fields for each, and then merge required flag in code.

But it will take 4 ajax calls if I have 3 content types associated with the list.

1

1 Answer 1

0

You could use batch rest api to reduce request to server.

Sample body.

--batch_e3b6819b-13c3-43bb-85b2-24b14122fed1
Content-Type: application/http
Content-Transfer-Encoding: binary

GET https://xxx.sharepoint.com/sites/lee/_api/web/lists/getByTitle('MyList')/ContentTypes('0x0100B0B77BE67D2DE8428E911932E5D0BEDD00D1EE82BD76FBE24EA6D917BE2FE7D769')/fields?$filter=Required%20eq%20true HTTP/1.1
Accept: application/json;odata=verbose

--batch_e3b6819b-13c3-43bb-85b2-24b14122fed1
Content-Type: application/http
Content-Transfer-Encoding: binary

GET https://xxx.sharepoint.com/sites/lee/_api/web/lists/getByTitle('MyList')/ContentTypes('0x01007BF91AB7D4095147B10280A02C55C97D')/fields?$filter=Required%20eq%20true HTTP/1.1
Accept: application/json;odata=verbose

--batch_e3b6819b-13c3-43bb-85b2-24b14122fed1--

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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