Batch
In Relativity, a system admin creates a batch by splitting a static set of documents into multiple sets based on the criteria for a review. For more information, see on the Relativity Documentation site.
The Services API supports read, update, delete, and query operations on the Batch DTO.
Note: You can also update and read batches using the single-artifact access methods common to all Relativity DTOs. For more information, see Single-artifact access.
This page contains the following information:
Update and read a Batch
When you update a Batch object, you can modify only the AssignedTo and BatchStatus properties. This code samples illustrates how to modify these properties using the Update() method on the Batch repository.
public static bool Batch_Update_Using_Repository(IRSAPIClient proxy)
{
// STEP 1: Create an object specifying the Artifact ID
// and the fields that you want returned.
DTOs.Batch batch1 = new DTOs.Batch(1036607);
batch1.Fields = FieldValue.AllFields;
// STEP 2: Read current values.
ResultSet<DTOs.Batch> results = new ResultSet<DTOs.Batch>();
try
{
results = proxy.Repositories.Batch.Read(batch1);
}
catch (Exception ex)
{
Console.WriteLine(string.Format("An error occurred: {0}", ex.Message));
return false;
}
if (!results.Success)
{
Console.WriteLine("Error: " + results.Message);
return false;
}
// STEP 3: Get the Artifact from the read results.
DTOs.Batch batch2 = results.Results.FirstOrDefault().Artifact;
Console.WriteLine("Batch Artifact ID: " + batch2.ArtifactID.ToString());
Console.WriteLine("Batch Text Identifier: " + batch2.TextIdentifier);
Console.WriteLine("Batch Status ID: " + batch2.BatchStatus.Name + ", ID: "
+ batch2.BatchStatus.ArtifactID.ToString());
Console.WriteLine("Batch Assigned To: " + batch2.AssignedTo.FullName + ",
ID: " + batch2.AssignedTo.ArtifactID.ToString());
// STEP 4: Modify properties of the Batch.
// For a Batch, you can only modify the AssignedTo and BatchStatus properties.
batch2.BatchStatus = new DTOs.Choice(1035249);
batch2.AssignedTo = new DTOs.User(1016508);
// STEP 5: Call the Update() method on the Batch repository.
WriteResultSet<DTOs.Batch> writeResultSet = null;
try
{
writeResultSet = proxy.Repositories.Batch.Update(new List<DTOs.Batch> { batch2 });
}
catch (Exception ex)
{
Console.WriteLine(string.Format("An error occurred: {0}", ex.Message));
return false;
}
if (writeResultSet.Success)
{
Console.WriteLine("Batch updated successfully");
batch2 = results.Results.FirstOrDefault().Artifact;
Console.WriteLine("Batch Artifact ID: " + batch2.ArtifactID.ToString());
Console.WriteLine("Batch Text Identifier: " + batch2.TextIdentifier);
Console.WriteLine("Batch Status ID: " + batch2.BatchStatus.ArtifactID.ToString());
Console.WriteLine("Batch Assigned To ID: " + batch2.AssignedTo.ArtifactID.ToString());
}
else
{
string message = writeResultSet.Message;
if (message == null && writeResultSet.Results.Count > 0 && !writeResultSet.Results[0].Success)
message = writeResultSet.Results[0].Message;
Console.WriteLine("Error: " + message);
return false;
}
// STEP 6: Read back the updated Artifact.
try
{
results = proxy.Repositories.Batch.Read(batch2);
}
catch (Exception ex)
{
Console.WriteLine(string.Format("An error occurred: {0}", ex.Message));
return false;
}
if (!results.Success)
{
Console.WriteLine("Error: " + results.Message);
return false;
}
// STEP 7: Get the updated property values from the read results.
DTOs.Batch batch3 = results.Results.FirstOrDefault().Artifact;
Console.WriteLine("Batch Artifact ID: " + batch3.ArtifactID.ToString());
Console.WriteLine("Batch Text Identifier: " + batch3.TextIdentifier);
Console.WriteLine("Batch Status: " + batch3.BatchStatus.Name + ", ID: " +
batch3.BatchStatus.ArtifactID.ToString());
Console.WriteLine("Batch Assigned To: " + batch3.AssignedTo.FullName + ",
ID: " + batch3.AssignedTo.ArtifactID.ToString());
return true;
}
Query for a Batch
To query for a Batch, you can use the fields listed in the following table. For more information, see Search Relativity.
Fields for Batch queries | |
---|---|
ArtifactID | Batch Size |
Assigned To | Batch Status |
Batch | Batch Unit |
Batch Set | Reviewed |
This code sample illustrates how to set query conditions, call the Query() method on the Batch repository, and iterate through the result set.
public static bool Batch_Query_By_BatchSet_Using_Repository(IRSAPIClient proxy)
{
// STEP 1: Create criteria that identifies a BatchSet object.
WholeNumberCondition criteria = new WholeNumberCondition(BatchFieldNames.BatchSet, NumericConditionEnum.EqualTo, 1036606);
// STEP 2: Create a query that uses your criteria.
DTOs.Query<DTOs.Batch> query = new DTOs.Query<DTOs.Batch>();
query.Condition = criteria;
query.Fields = FieldValue.AllFields;
// STEP 3: Call the Query() method on the Batch repository.
QueryResultSet<DTOs.Batch> result = null;
try
{
result = proxy.Repositories.Batch.Query(query);
}
catch (Exception ex)
{
Console.WriteLine(string.Format("An error occurred: {0}", ex.Message));
return false;
}
Console.WriteLine(string.Format("Number of batches returned: {0}", result.Results.Count));
// STEP 3: Iterate through returned the results.
foreach (DTOs.Result<DTOs.Batch> batchResult in result.Results)
{
DTOs.Batch batch = batchResult.Artifact;
Console.WriteLine("Batch Name: " + batch.Name);
Console.WriteLine("Batch Artifact ID: " + batch.ArtifactID);
}
return true;
}