1
votes

Using core service how can we check if a field allow multiple values, below is the code I'm using to get the type of field:-

SchemaFieldsData fields = client.ReadSchemaFields(schemaTCMURI, true, new ReadOptions());

                foreach (var field in fields.MetadataFields)
                {
                    if (field is SingleLineTextFieldDefinitionData)
                    {
                        // some code
                    }
                    else if (field is MultiLineTextFieldDefinitionData)
                    {
                // this will check only if field is multiline not multi valued                        }

}

Please suggest.

2

2 Answers

5
votes

You need to check the MinOccurs and MaxOccurs properties. If MinOccurs is 0 the field is optional, otherwise it's mandatory. If MaxOccurs is 1, the field is single-value. Otherwise it's multi-value.

3
votes

According to Core Service documentation, you can check for field. MaxOccurs

  • MaxOccurs == 1 means single valued field

  • MaxOccurs == - 1 means means valued field