createField method

Future<CreateFieldResponse> createField({
  1. required String domainId,
  2. required String name,
  3. required FieldType type,
  4. FieldAttributes? attributes,
  5. String? description,
})

Creates a field in the Cases domain. This field is used to define the case object model (that is, defines what data can be captured on cases) in a Cases domain.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter domainId : The unique identifier of the Cases domain.

Parameter name : The name of the field.

Parameter type : Defines the data type, some system constraints, and default display of the field.

Parameter attributes : Union of field attributes.

Parameter description : The description of the field.

Implementation

Future<CreateFieldResponse> createField({
  required String domainId,
  required String name,
  required FieldType type,
  FieldAttributes? attributes,
  String? description,
}) async {
  final $payload = <String, dynamic>{
    'name': name,
    'type': type.value,
    if (attributes != null) 'attributes': attributes,
    if (description != null) 'description': description,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/domains/${Uri.encodeComponent(domainId)}/fields',
    exceptionFnMap: _exceptionFns,
  );
  return CreateFieldResponse.fromJson(response);
}