In Relativity, choices are predetermined values of single and multi-choice list fields. You can perform operations on admin and workspace choices. For more general information, see
The Choice Manager API exposes multiple operations you can use to programmatically manage choices in your Relativity environment. It includes the following features:
A sample use case for the Choice Manager API service is a custom application that includes choices you want to perform operations with.
You can also use the Choice Manager service through the REST API. For more information, see Choice Manager service.
This page contains the following information:
Review the following information to learn about the methods, classes, and other entities used by the Choice Manager service.
In the Relativity Services API, the Relativity.Services.Interfaces namespace contains the IChoiceManager interface that exposes the following methods:
Relativity.Services.Interfaces.Choice.Models namespace contains the following classes and enumerations used by the Choice Manager API:
The following code sample illustrates how to create a single choice asynchronously with the IChoiceManager interface using the await pattern.
public async Task<int> CreateChoiceAsync(IHelper helper, int workspaceID){ using (IChoiceManager choiceManagerProxy = helper.GetServicesManager().CreateProxy<IChoiceManager>(ExecutionIdentity.User)) { try { ChoiceRequest choiceRequest = new ChoiceRequest(); // This field will contain the new choice choiceRequest.Field = new Relativity.Services.Interfaces.Shared.Models.ObjectIdentifier() { ArtifactID = 1234567 }; choiceRequest.Name = "Choice Tester 2"; choiceRequest.Color = 3; choiceRequest.Keywords = ""; choiceRequest.Notes = ""; return await choiceManagerProxy.CreateAsync(workspaceID, choiceRequest); } catch (Exception exception) { logger.LogError(exception, "The Choice could not be created."); } } return null; }
The following code sample illustrates how to mass create choices asynchronously with the IChoiceManager interface using the await pattern.
public async Task<MassCreateChoiceResponse> MassCreateAsync(IHelper helper, int workspaceID) { using (IChoiceManager choiceManagerProxy = helper.GetServicesManager().CreateProxy<IChoiceManager>(ExecutionIdentity.User)) { try { MassCreateChoiceStructure<string> choiceOne = new MassCreateChoiceStructure<string> { Name = "Choice 1", //The childrens will be created if the field type is MultipleChoice Children = new List<MassCreateChoiceStructure<string>>() { new MassCreateChoiceStructure<string>() { Name = "Choice 1.1" }, new MassCreateChoiceStructure<string>() { Name = "Choice 1.2" } } }; MassCreateChoiceStructure<string> choiceTwo = new MassCreateChoiceStructure<string> { Name = "Choice 2" }; MassCreateChoiceRequest massCreateRequest = new MassCreateChoiceRequest { Choices = new List<MassCreateChoiceStructure<string>> { choiceOne, choiceTwo }, ChoiceTemplateData = new MassCreateChoiceModel() { Field = new Interfaces.Shared.Models.ObjectIdentifier() { ArtifactID = fieldDTO.ArtifactID }, Keywords = "", Notes = "", RelativityApplications = new List<Interfaces.Shared.Models.ObjectIdentifier>() } }; return await choiceManagerProxy.CreateAsync(workspaceID, massCreateRequest); } catch (Exception exception) { _logger.LogError(exception, "The Choices could not be created."); } } return null; }
The following code sample illustrates how to read a single choice asynchronously with the IChoiceManager interface using the await pattern.
public async Task<ChoiceResponse> ReadChoiceAsync(IHelper helper, int workspaceID, int choiceID, bool includeMetadata, bool includeActions) { using (IChoiceManager choiceManagerProxy = helper.GetServicesManager().CreateProxy<IChoiceManager>(ExecutionIdentity.User)) { try { return await choiceManagerProxy.ReadAsync(workspaceID, choiceID, includeMetadata, includeActions); } catch (Exception exception) { _logger.LogError(exception, "The Choice could not be read."); } } return null; }
The following code sample illustrates how to mass update choices asynchronously using the IChoiceManager interface with await pattern.
public async Task UpdateChoiceAsync(IHelper helper, int workspaceID, int choiceID) { using (IChoiceManager choiceManagerProxy = helper.GetServicesManager().CreateProxy<IChoiceManager>(ExecutionIdentity.User)) { try { ChoiceRequest choiceRequest = new ChoiceRequest(); // This field will contain the new choice choiceRequest.Field = new Relativity.Services.Interfaces.Shared.Models.ObjectIdentifier() { ArtifactID = 1234567 }; choiceRequest.Name = "Choice Update"; choiceRequest.Color = 3; choiceRequest.Keywords = ""; choiceRequest.Notes = ""; choiceRequest.KeyboardShortcut = new Interfaces.Shared.Models.KeyboardShortcutCombination() { Alt = false, Ctrl = true, Shift = false, Key = 14 }; await choiceManagerProxy.UpdateAsync(workspaceID, choiceID, choiceRequest); } catch (Exception exception) { _logger.LogError(exception, "The Choice could not be updated."); } } }
The following code sample illustrates how to update a single choice asynchronously using the IChoiceManager interface with await pattern.
The following code sample illustrates how to delete a single choice asynchronously using the IChoiceManager interface with await pattern.
public async Task DeleteChoiceAsync(IHelper helper, int workspaceID, int choiceID) { using (IChoiceManager choiceManagerProxy = helper.GetServicesManager().CreateProxy<IChoiceManager>(ExecutionIdentity.User)) { try { await choiceManagerProxy.DeleteAsync(workspaceID, choiceID); } catch (Exception exception) { _logger.LogError(exception, "The Choice could not be deleted."); } } }
The following code sample illustrates how to mass delete choices asynchronously with the IChoiceManager interface using the await pattern.
public async Task<MassActionChoiceResponse> MassDeleteAsync(IHelper helper, int workspaceID, List<ObjectIdentifier> choicesID) { using (IChoiceManager choiceManagerProxy = helper.GetServicesManager().CreateProxy<IChoiceManager>(ExecutionIdentity.User)) { try { MassDeleteChoiceRequest massDeleteChoiceRequest = new MassDeleteChoiceRequest(); massDeleteChoiceRequest.ChoiceIDs = choicesID; return await choiceManagerProxy.DeleteAsync(workspaceID, massDeleteChoiceRequest); } catch (Exception exception) { _logger.LogError(exception, "The Choice could not be deleted."); } } return null; }
The following code sample illustrates how to sort choices alphabetically with the IChoiceManager interface using the await pattern.
public async Task<MassActionChoiceResponse> SortAsync(IHelper helper, int workspaceID, int fieldID, ChoiceReorderTypeEnum choiceReorderType) { using (Interfaces.Choice.IChoiceManager choiceManagerProxy = helper.GetServicesManager().CreateProxy<IChoiceManager>(ExecutionIdentity.User)) { try { return await choiceManagerProxy.SortAsync(workspaceID, fieldID, choiceReorderType); } catch (Exception exception) { _logger.LogError(exception, "The Choices could not be sorted."); } } return null; }
The following code sample illustrates how to move choices to the beginning or end of a list of choices with the IChoiceManager interface using the await pattern.
public async Task<MassActionChoiceResponse> MoveAsync(IHelper helper, int workspaceID, int fieldID, ObjectIdentifier[] choiceObjectIdentifiers, ChoiceMoveTypeEnum choiceMoveType) { using (IChoiceManager choiceManagerProxy = helper.GetServicesManager().CreateProxy<IChoiceManager>(ExecutionIdentity.User)) { try { return await choiceManagerProxy.MoveAsync(workspaceID, fieldID, choiceObjectIdentifiers, choiceMoveType); } catch (Exception exception) { _logger.LogError(exception, "The Choices could not be moved."); } } return null; }
The following code sample illustrates how to move a choice after a specific choice in a list of choices with the IChoiceManager interface using the await pattern.
public async Task<MassActionChoiceResponse> MoveAsync(IHelper helper, int workspaceID, int fieldID, ObjectIdentifier[] choiceObjectIdentifiers, ObjectIdentifier choiceIdentifier) { using (IChoiceManager choiceManagerProxy = helper.GetServicesManager().CreateProxy<IChoiceManager>(ExecutionIdentity.User)) { try { return await choiceManagerProxy.MoveAsync(workspaceID, fieldID, choiceObjectIdentifiers, choiceIdentifier); } catch (Exception exception) { _logger.LogError(exception, "The Choices could not be moved."); } } return null; }
The following code sample illustrates how to retrieve a list of available parents for a specific choice or field with the IChoiceManager interface using the await pattern.
public async Task<List<ObjectIdentifier>> GetAvailableParentsListAsync(IHelper helper, int workspaceID, int choiceID) { using (IChoiceManager choiceManagerProxy = helper.GetServicesManager().CreateProxy<IChoiceManager>(ExecutionIdentity.User)) { try { return await choiceManagerProxy.GetAvailableParentsListAsync(workspaceID, choiceID); } catch (Exception exception) { _logger.LogError(exception, "The parent choices could not be retrieved."); } } return null; }
The following code sample illustrates how to retrieve a list of available colors that can be assigned to choices with the IChoiceManager interface using the await pattern.
public async Task<List<NameIDPair>> GetAvailableParentsListAsync(IHelper helper, int workspaceID) { using (IChoiceManager choiceManagerProxy = helper.GetServicesManager().CreateProxy<IChoiceManager>(ExecutionIdentity.User)) { try { return await choiceManagerProxy.GetColorsListAsync(workspaceID); } catch (Exception exception) { _logger.LogError(exception, "The colors could not be retrieved."); } } return null; }
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 |