View
Relativity uses views to provide customizable item lists. For more information, see Views on the Relativity Documentation site.
The Services API supports read and query operations on a View DTO. You can also read views using the common DTO ReadSingle method. For more information, see Single-artifact access.
Note: See View Manager API for information about the View Manager API, and View Manager service for information about using this service through REST.
This page contains the following information:
Read a View
To read Field values on a View, you can use the Read() method on the View repository as illustrated in this code sample.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | public static bool ReadView(IRSAPIClient proxy, int viewID, int workspaceID) { proxy.APIOptions.WorkspaceID = workspaceID; // STEP 1: Create the View object. View viewObj = new View(viewID); // This will return all possible fields in the views collection. viewObj.Fields = FieldValue.AllFields; ResultSet<View> viewReadResults = new ResultSet<View>(); // STEP 2: Try to read the View. try { viewReadResults = proxy.Repositories.View.Read(viewObj); } catch (Exception ex) { Console.WriteLine( "An error occurred reading the view: {0}" , ex.Message); } // STEP 3: Check for success. if (!viewReadResults.Success) { Console.WriteLine( "An error occurred reading the view: {0}" , viewReadResults.Message); foreach (Result<View> readResult in viewReadResults.Results) { if (!readResult.Success) { Console.WriteLine( " An error occurred in read request: {0}" , readResult.Message); } } return false ; } // STEP 4: Display the results. Console.WriteLine( "Successfully read the view '{0}'!" , viewReadResults.Results[0].Artifact.Name); return true ; } |
Query for a View
This code sample illustrates how to set query conditions, call the Query() method on the View repository, and iterate through the result set.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | public static bool QueryView(IRSAPIClient proxy, int viewID, int workspaceID) { proxy.APIOptions.WorkspaceID = workspaceID; // STEP 1: Create the Query criteria. Here the condition looks for any views with an Artifact ID. WholeNumberCondition queryCondition = new WholeNumberCondition( "Artifact ID" , NumericConditionEnum.IsSet); Query<View> viewQuery = new Query<View>(); viewQuery.Condition = queryCondition; // This will return all possible fields in the views collection. viewQuery.Fields = FieldValue.AllFields; ResultSet<View> viewQueryResults = new ResultSet<View>(); // STEP 2: Try to query for the View. try { viewQueryResults = proxy.Repositories.View.Query(viewQuery); } catch (Exception ex) { Console.WriteLine( "An error occurred while querying: {0}" , ex.Message); } // STEP 3: Check for success. if (!viewQueryResults.Success) { Console.WriteLine( "An error occurred while querying: {0}" , viewQueryResults.Message); return false ; } // STEP 4: Display the results. foreach (Result<View> singleView in viewQueryResults.Results) { View singleViewArtifact = singleView.Artifact; Console.WriteLine( "\r\nView Name: {0}\r\nView ID: {1}" , singleViewArtifact.Name, singleViewArtifact.ArtifactID); } return true ; } |