I am trying to list all mandatory fields in a Schema via a custom Core Service project. I don't see that field in the SchemaFieldsData (or probably I am overlooking it).

Is there a way I can determine if a field is configured as mandatory or not?

SchemaFieldsData schemaFieldsData = Client.ReadSchemaFields(txtSchTCMURI, true, null);

2 Answers 2


To elaborate on Rob's answer, the code to add to yours would be something like:

SchemaFieldsData schemaFieldsData = Client.ReadSchemaFields(txtSchTCMURI, true, null);

foreach (var schemaField in schemaFieldsData.Fields)
    bool isMandatory = schemaField.MinOccurs > 0;
    // Do something with isMandatory

or perhaps

var mandatoryFields = schemaFieldsData.Fields.Where(field => field.MinOccurs > 0);
  • Thank you David, Rob's answer was helpful, but was waiting for a better answer as he suggested.. Thanks for the code snippet though :)..
    – Harish A
    May 17, 2017 at 13:38
  • Not sure how much simpler you can get than just loading the schema fields and sorting through them, but ok :) May 17, 2017 at 13:44
  • Yes, this is simpler.. but as he mentioned he was still doubtful about that approach.. anyways, thanks all :)
    – Harish A
    May 17, 2017 at 13:53
  • Hmm... looks like I accidentally downvoted this. Now SE won't let me undo it unless there's an edit. Please accept this virtual +1 as recompense. May 17, 2017 at 19:29
  • @HarishA This is a better answer and David deserves the points really! May 17, 2017 at 19:53

I think you need to look at the MinOccurs and MaxOccurs on each field. MinOccurs will be 1 for mandatory fields. Remember the Schema is an XSD.

There's probably a simpler way but I've never done this before.

See here for example of creating the fields: http://docs.sdl.com/LiveContent/content/en-US/SDL%20Web-v1/GUID-5A946CBF-36D3-4D11-BE04-4901F9ED88E3


Your Answer

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

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