Show / Hide Table of Contents

Interface IFieldService

Represents the field API service.

Namespace: Relativity.Testing.Framework.Api.Services
Assembly: Relativity.Testing.Framework.Api.dll
Syntax
public interface IFieldService
Examples
_fieldService = relativityFacade.Resolve<IFieldService>();

Methods

| Improve this Doc View Source

Create<TFieldModel>(Int32, TFieldModel)

Creates the specified field.

Declaration
TFieldModel Create<TFieldModel>(int workspaceId, TFieldModel entity)

    where TFieldModel : Field
Parameters
Type Name Description
System.Int32 workspaceId

The Artifact ID of the workspace where you want to add the new field, or use -1 to indicate the admin-level context.

TFieldModel entity

The entity to create.

Returns
Type Description
TFieldModel

The created entity.

Type Parameters
Name Description
TFieldModel

The field type.

Examples
var workspaceId = 1015427;
var fieldForPropagation = _fieldService.Get(workspaceId, "MD5 Hash");
WholeNumberField fieldToCreate = new WholeNumberField
{
	PropagateTo = new FieldPropagate
	{
		ViewableItems = new List<Artifact>
		{
			new Artifact
			{
				ArtifactID = fieldForPropagation.ArtifactID
			}
		}
	}
};
var createdField = _fieldService.Create(workspaceId, fieldToCreate);
| Improve this Doc View Source

Delete(Int32, Int32)

Deletes the field by ID.

Declaration
void Delete(int workspaceId, int entityId)
Parameters
Type Name Description
System.Int32 workspaceId

The Artifact ID of the workspace where you want to delete the field, or use -1 to indicate the admin-level context.

System.Int32 entityId

The artifact ID of the field.

Examples
var workspaceId = 1015427;
var someExistingFieldArtifactId = 1;
_fieldService.Delete(workspaceId, someExistingFieldArtifactId);
| Improve this Doc View Source

Get(Int32, Int32)

Gets the field by the specified ID. Returns only base parameters of field.

Declaration
Field Get(int workspaceId, int entityId)
Parameters
Type Name Description
System.Int32 workspaceId

The Artifact ID of the workspace where you want to get the field, or use -1 to indicate the admin-level context.

System.Int32 entityId

The artifact ID of the field.

Returns
Type Description
Field

The Field entity or null.

Examples
var workspaceId = 1015427;
var someExistingFieldArtifactId = 1;
var fieldWithBaseParameters = _fieldService.Get(workspaceId, someExistingFieldArtifactId);
| Improve this Doc View Source

Get(Int32, String)

Gets the field by the specified name. Returns only base parameters of field.

Declaration
Field Get(int workspaceId, string entityName)
Parameters
Type Name Description
System.Int32 workspaceId

The Artifact ID of the workspace where you want to get the field, or use -1 to indicate the admin-level context.

System.String entityName

The name of the object type.

Returns
Type Description
Field

The Field entity or null.

Examples
var workspaceId = 1015427;
var fieldWithBaseParameters = _fieldService.Get(workspaceId, "Some Existing Field Name");
| Improve this Doc View Source

Get<TFieldModel>(Int32, Int32)

Gets the field of specified type by the specified ID.

Declaration
TFieldModel Get<TFieldModel>(int workspaceId, int entityId)

    where TFieldModel : Field
Parameters
Type Name Description
System.Int32 workspaceId

The Artifact ID of the workspace where you want to get the field, or use -1 to indicate the admin-level context.

System.Int32 entityId

The artifact ID of the field.

Returns
Type Description
TFieldModel

The Field entity or null.

Type Parameters
Name Description
TFieldModel

The field type.

Examples
var workspaceId = 1015427;
var someExistingYesNoFieldArtifactId = 1;
var yesNoField = _fieldService.Get<YesNoField>(workspaceId, someExistingYesNoFieldArtifactId);
| Improve this Doc View Source

Get<TFieldModel>(Int32, String)

Gets the field of specified type by the specified name.

Declaration
TFieldModel Get<TFieldModel>(int workspaceId, string entityName)

    where TFieldModel : Field
Parameters
Type Name Description
System.Int32 workspaceId

The Artifact ID of the workspace where you want to get the field, or use -1 to indicate the admin-level context.

System.String entityName

The name of the field.

Returns
Type Description
TFieldModel

The Field entity or null.

Type Parameters
Name Description
TFieldModel

The field type.

Examples
var workspaceId = 1015427;
var currencyField = _fieldService.Get<CurrencyField>(workspaceId, "Some Existing Currency Field Name");
| Improve this Doc View Source

Require<TFieldModel>(Int32, TFieldModel)

Requires the specified field.

  1. If [ArtifactID](https://relativitydev.github.io/relativity.testing.framework/api/Relativity.Testing.Framework.Models.Artifact.html#Relativity_Testing_Framework_Models_Artifact_ArtifactID) property of entity has positive value, gets entity by ID and updates it.
  2. If [Name](https://relativitydev.github.io/relativity.testing.framework/api/Relativity.Testing.Framework.Models.NamedArtifact.html#Relativity_Testing_Framework_Models_NamedArtifact_Name) property of entity has a value, gets entity by name and updates it if it exists.
  3. Otherwise creates a new entity.
Declaration
TFieldModel Require<TFieldModel>(int workspaceId, TFieldModel entity)

    where TFieldModel : Field
Parameters
Type Name Description
System.Int32 workspaceId

The Artifact ID of the workspace where you want to update the field, or use -1 to indicate the admin-level context.

TFieldModel entity

The entity to update.

Returns
Type Description
TFieldModel

The entity required.

Type Parameters
Name Description
TFieldModel

The field type.

Examples
var workspaceId = 1015427;
var fieldForPropagation = _fieldService.Get(workspaceId, "MD5 Hash");
var existingFieldArtifactId = 1;
var existingObjectType = relativityFacade.Resolve<IObjectTypeService>().Get(workspaceId, "Document");
var fieldToUpdate = new SingleChoiceField
{
	PropagateTo = new FieldPropagate
	{
		ViewableItems = new List<Artifact>
		{
			new Artifact(fieldForPropagation.ArtifactID)
		},
	},
	Name = "Some Updated Name",
	ArtifactID = existingFieldArtifactId,
	ObjectType = existingObjectType
};
var updatedField = _fieldService.Require(workspaceId, fieldToUpdate); // Will get field by ArtifactId, update it and return updated
var workspaceId = 1015427;
var fieldForPropagation = _fieldService.Get(workspaceId, "MD5 Hash");
var existingObjectType = relativityFacade.Resolve<IObjectTypeService>().Get(workspaceId, "Document");
var fieldToUpdate = new MultipleChoiceField
{
	PropagateTo = new FieldPropagate
	{
		ViewableItems = new List<Artifact>
		{
			new Artifact(fieldForPropagation.ArtifactID)
		},
		Name = "Some Existing Field Name",
		ObjectType = existingObjectType
};
var updatedField = _fieldService.Require(workspaceId, fieldToUpdate); // Will get field by Name, update it and return updated
var workspaceId = 1015427;
var fieldForPropagation = _fieldService.Get(workspaceId, "MD5 Hash");
FixedLengthTextField fieldToCreate = new FixedLengthTextField
{
	PropagateTo = new FieldPropagate
	{
		ViewableItems = new List<Artifact>
		{
			new Artifact(fieldForPropagation.ArtifactID)
		}
	},
	Unicode = true
};
var createdField = _fieldService.Require(workspaceId, fieldToCreate); // Will create new FixedLengthTextField
| Improve this Doc View Source

Update<TFieldModel>(Int32, TFieldModel)

Updates the specified field.

Declaration
void Update<TFieldModel>(int workspaceId, TFieldModel entity)

    where TFieldModel : Field
Parameters
Type Name Description
System.Int32 workspaceId

The Artifact ID of the workspace where you want to update the field, or use -1 to indicate the admin-level context.

TFieldModel entity

The entity to update.

Type Parameters
Name Description
TFieldModel

The field type.

Examples
var workspaceId = 1015427;
var fieldForPropagationArtifactId = 2;
var userFieldToUpdate = new UserField
{
	PropagateTo = new FieldPropagate
	{
		ViewableItems = new List<Artifact>
		{
			new Artifact
			{
				ArtifactID = fieldForPropagationArtifactId
			}
		}
	},
	OpenToAssociations = true,
	Name = "Updated Name"
};
_fieldService.Update(workspaceId, userFieldToUpdate);
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX