Relativity Services API (RSAPI) DTOs have been deprecated in 11.3 and are no longer supported. For more information and alternative APIs, see RSAPI deprecation process.

ObjectType

An ObjectType is Relativity Dynamic Object (RDO) type that you add to a workspace. It is synonymous with ArtifactType. For more information, see Creating and editing Relativity Objects.

The Services API supports all CRUD and query operations on a ObjectType DTO.

Note: You can also perform a full set of CRUD operations on object types using the single-artifact access methods common to all Relativity DTOs. For more information, see Single-artifact access.

This page contains the following information:

Create an ObjectType

You can add an ObjectType to Relativity by calling the Create() method on the ObjectType repository as illustrated in this code sample.

public bool Create_ObjectType_Single(IRSAPIClient proxy, IAPILog logger, int workspaceId)
{   
    // Set the workspace ID
    proxy.APIOptions.WorkspaceID = workspaceId;

    // Create an ObjectType DTO
    var objectTypeDTO = new kCura.Relativity.Client.DTOs.ObjectType();

    // Set primary fields
    // The name of the sample data is being set to a random string so that sample data 
    // can be debugged and never causes collisions. 
    // You can set this to any string that you want
    objectTypeDTO.Name = string.Format("API {0}", Guid.NewGuid());
    // 8 = Workspace type as parent
    objectTypeDTO.ParentArtifactTypeID = 8;
    objectTypeDTO.SnapshotAuditingEnabledOnDelete = true;
    objectTypeDTO.Pivot = true;
    objectTypeDTO.CopyInstancesOnWorkspaceCreation = false;
    objectTypeDTO.Sampling = true;
    objectTypeDTO.PersistentLists = false;
    
    // Set optional fields such as Relativity application
    objectTypeDTO.CopyInstancesOnParentCopy = true;

    // Perform the create in a try/catch in case it fails
    try
    {
        int objectTypeID = proxy.Repositories.ObjectType.CreateSingle(objectTypeDTO);
        logger.LogDebug("The new ObjectType Artifact ID is: {ObjectTypeID}", objectTypeID);
    }
    catch (Exception ex)
    {
        logger.LogError(ex, "Unhandled Exception");
        return false;
    }

    return true;
}      

Note the use of the CopyInstancesOnParentCopy property to set the ObjectType to automatically copy the instances of the object when its parent object is copied. You cannot set the CopyInstanceOnParentCopy to True if the parent artifact type is Workspace. If you attempt to do that, a validation error is thrown. That scenario is covered by the CopyInstancesOnWorkspaceCreation property.

Read an ObjectType

To read Field values, you can use the Read() method on the ObjectType repository as illustrated in this code sample.

public static bool Read_ObjectType_Using_Repository(IRSAPIClient proxy, 
                                                    int workspaceId, 
                                                    int objectTypeId)
{
    proxy.APIOptions.WorkspaceID = workspaceId;
       
    // Call the Read() method on the ObjectType repository and pass an ObjectType DTO.
    // ObjectType = kCura.Relativity.Client.DTOs.ObjectType
    ResultSet<ObjectType> results;
    try 
    {
        results = 
            proxy.Repositories.ObjectType.Read(
                new ObjectType(objectTypeId) 
                { 
                    Fields = FieldValue.AllFields 
                });
    }
    catch (Exception ex) 
    {
          Console.WriteLine("Error: {0}", ex.Message);
          return false;
    }
       
    if (!results.Success) 
    {
        Console.WriteLine("Error: {0}", results.Message);
            
        foreach (Result<ObjectType> result in results.Results)
        {
               Console.WriteLine("Result Error: {0}", result.Message);
        }
        return false;
    }
       
    // Get the Object Type artifact from the read results.
    ObjectType objectTypeArtifact = results.Results.FirstOrDefault().Artifact;
       
    Console.WriteLine("Object Type Artifact ID: {0}", objectTypeArtifact.ArtifactID);
    Console.WriteLine("Object Type Name: {0}", objectTypeArtifact.Name);
    Console.WriteLine("Object Type Artifact Type ID: {0}", 
        objectTypeArtifact.DescriptorArtifactTypeID);
       
    return true;
}        

Update an ObjectType

You can use the Update() method on the ObjectType repository to modify its properties as illustrated in this code sample.

public static bool Update_ObjectType_Using_Repository(IRSAPIClient proxy, 
                                                      int workspaceId,
                                                      int objectTypeId)
{
    proxy.APIOptions.WorkspaceID = workspaceId;
        
    // Create an ObjectType DTO and populate the Fields you want to update.
    var objectTypeDTO = new kCura.Relativity.Client.DTOs.ObjectType(objectTypeId);
    objectTypeDTO.Name = "Renamed Object Type";
        
    // Call the Update() method on the repository and pass the DTO.
    // ObjectType = kCura.Relativity.Client.DTOs.ObjectType
    WriteResultSet<ObjectType> resultSet;
    try 
    {
        resultSet = proxy.Repositories.ObjectType.Update(objectTypeDTO);
    }
    catch (Exception ex) 
    {
        Console.WriteLine("Error: {0}", ex.Message);
        return false;
    }
    
    if (!resultSet.Success) 
    {
        Console.WriteLine("Error: {0}", resultSet.Message);
        
        foreach (Result<ObjectType> result in resultSet.Results) 
        {
            Console.WriteLine("Result Error: {0}", result.Message);
        }
        return false;
    }
    
    Console.WriteLine("Overall status of Updating an object type: {0}", resultSet.Success);
    
    // Read back the Artifact for verification.
    ResultSet<ObjectType> readResult;
    try 
    {
        readResult = proxy.Repositories.ObjectType.Read(objectTypeDTO);
    }
    catch (Exception ex) 
    {
        Console.WriteLine("Error: {0}", ex.Message);
        return false;
    }
    
    if (!readResult.Success) 
    {
        Console.WriteLine("Error: {0}", readResult.Message);
        foreach (Result<DTOs.ObjectType> result in resultSet.Results) 
        {
            Console.WriteLine("Result Error: {0}", result.Message);
        }
        return false;
    }
        
    Console.WriteLine("Updated Object Type Name: {0}", 
        readResult.Results.FirstOrDefault().Artifact.Name);
    
    return true;
}       

Delete an ObjectType

You can remove an ObjectType from Relativity by calling the Delete() method on the ObjectType repository as illustrated in this code sample.

public static bool Delete_ObjectType_Using_Repository(IRSAPIClient proxy,
                                                      int workspaceId,
                                                      int objectTypeIdToDelete)
{
    proxy.APIOptions.WorkspaceID = workspaceId;

    // Call the delete method on the ArtifactType Repository, passing the ObjectType DTO.
    // ObjectType = kCura.Relativity.Client.DTOs.ObjectType           
    ResultSet<ObjectType> results;
    try 
    {
        results = proxy.Repositories.ObjectType.Delete(new DTOs.ObjectType(objectTypeIdToDelete));
    }
    catch (Exception ex) 
    {
        Console.WriteLine("Error: {0}", ex.Message);
        return false;
    }

    if (results.Success)
    {
        Console.WriteLine("Status of Delete: {0}", results.Success);
    }
        
    else
    {
        Console.WriteLine("Error deleting object type: {0}", results.Results[0].Message);
    }
    return true;
}     

Query for an ObjectType

This code sample illustrates how to set query conditions, call the Query() method on the ObjectType repository, and iterate through the result set.

public static bool Query_ObjectType_Using_Repository(IRSAPIClient proxy)
{
    // Setup your query criteria.
    TextCondition criteria = 
        new kCura.Relativity.Client.TextCondition(
            kCura.Relativity.Client.DTOs.ObjectTypeFieldNames.Name, 
            TextConditionEnum.EqualTo, 
            "Employees");
    
    // Query = kCura.Relativity.Client.DTOs.Query
    // ObjectType = kCura.Relativity.Client.DTOs.ObjectType
    Query<ObjectType> query = new Query<ObjectType>
    {
        Condition = criteria,
        Fields = FieldValue.AllFields
    };
    
    // Call the Query() method in the ObjectType repository.
    QueryResultSet<ObjectType> result = new QueryResultSet<ObjectType>();
    try 
    {
        result = proxy.Repositories.ObjectType.Query(query, 0);
    }
    catch (Exception ex) 
    {
        Console.WriteLine("An error occurred: {0}", ex.Message);
        return false;
    }
    
    Console.WriteLine("Number of documents returned: {0}", result.TotalCount);
    Console.WriteLine("Additional Pages of Query Results Available?: {0}", 
        !string.IsNullOrEmpty(result.QueryToken));
    
    // Iterate over the returned ObjectType results.
    foreach (Result<ObjectType> objTypeResult in result.Results) 
    {
        ObjectType objType = objTypeResult.Artifact;
        Console.WriteLine("Object Type Name: {0}", objTypeResult.Artifact.Name);
        Console.WriteLine("Object Type Artifact Type ID: {0}", 
            objTypeResult.Artifact.DescriptorArtifactTypeID);
    }
    
    return true;
}    

Community Updates

Aero Developer FAQ Evolving the Platform Most recent release notes
Learn more Learn more Learn more

Additional Resources

   
Access Third-Party Tools with GitHub     Create .NET Apps Faster with NuGet
Visit github     visit nuget