1

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.

Nuno Linhares
  • 10,214
  • 1
  • 22
  • 42
SDL Developer
  • 612
  • 1
  • 5
  • 15

2 Answers2

5

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.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
3

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

  • MaxOccurs == 1 means single valued field

  • MaxOccurs == - 1 means means valued field

Puntero
  • 2,310
  • 15
  • 18