Pivot Manager service

The Relativity REST API includes a Pivot Manager service that provides operations for working with custom Pivot queries and Pivot profiles. You can use the service to create and run custom Pivot queries and to read and run queries that are based on existing Pivot profiles. The supported operations are equivalent to the supported methods for interacting with Pivot objects in the Relativity Services API. Unlike the Services API however, the Pivot Manager service doesn’t support use of progress indicators or cancellation tokens.

This page contains the following sections:

Note that the Pivot Manager service doesn’t provide operations for creating, updating, or deleting Pivot queries that persist in Relativity. This means that you can use the service to create and run a custom query but you can’t store and subsequently update or delete the query or query results in Relativity. Similarly, you can use the service to read an existing Pivot profile and run a query that’s based on the profile, but you can’t create, update, or delete a Pivot profile. Overall, the service is designed to help you transfer data to other applications and tools, such as a third-party software application or web-based visualization tool, for deeper analysis and reporting. For example, you might use the service to implement a Pivot query as part of a larger solution that captures query results, writes the results to a specified table, object, or other location, and then manipulates the results in that location.

Pivot fundamentals

To interact with the Pivot Manager service, you send HTTP(S) requests that use the POST method and specify query conditions in the body of the request. All Pivot requests use the following base URL:

http://localhost/relativity.rest/api/Relativity.Services.Pivot.IPivotModule/Pivot%20Manager/

For example, use the following URL to create and run a custom Pivot query:

http://localhost/relativity.rest/api/Relativity.Services.Pivot.IPivotModule/Pivot%20Manager/ExecuteAsync

Or use the following URL to read and run a query based on a Pivot profile:

http://localhost/relativity.rest/api/Relativity.Services.Pivot.IPivotModule/Pivot%20Manager/ExecutePivotProfileAsync

Note that the base URL format for the Pivot Manager service is different from most other Relativity REST services.

Like other query-based services of the Relativity REST API, request bodies and server responses for the Pivot Manager service are sent in JSON payloads. The body of a POST request for a query includes a JSON representation of fields, conditions, and other parameters for the query. The body of a response returns all the query results as a single result set; the Pivot Service Manager doesn’t provide built-in support for paging. For information about the options and syntax that you can use for Pivot and other query services in the Relativity REST API, see Query for resources.

Fields

The Pivot Manager service uses a combination of unique fields and fields that are common to the Relativity REST API. The following table lists and describes the required fields for the Pivot Manager service and indicates whether each field is common to the REST API or specific to a type of Pivot query. For more information about a common field, see JSON representations. Note that field names are case-sensitive.

Field Type Description Scope
ArtifactTypeID Number The Artifact Type identifier of the type of DTO to query—for example, “10” for documents. Common
GroupBy Object The view field identifier, Artifact identifier, GUID, or name of the field to use for grouping data. Custom Pivot queries only
GroupByDateGrouping Number The calendar-based time interval to use when calculating data for the GroupBy field, if the GroupBy field is a Date field:

0 = Day, month, and year

1 = Month

2 = Year

3 = Month and year

Custom Pivot queries only
objectSetQuery Object The name of a query that defines the criteria that objects or documents must meet to be included in the Pivot query. To query all objects or documents in a workspace, don’t specify a value for the condition of this field. Common
PivotOn Object The view field identifier, Artifact identifier, GUID, or name of the field to use for pivoting data. Custom Pivot queries only
PivotOnDateGrouping Number The calendar-based time interval to use when calculating data for the PivotOn field, if the PivotOn field is a Date field:

0 = Day, month, and year

1 = Month

2 = Year

3 = Month and year

Custom Pivot queries only
pivotProfileId Number The Artifact identifier of the Pivot profile to read and run. Profile-based queries only
RawDataOnly Boolean Whether to apply a Pivot view to query results. If “true”, only the data is returned. Custom and profile-based queries
Timeout Number The maximum amount of time, in seconds, to run the query before timing out. Custom and profile-based queries
Toggles Object The Toggles property on a Pivot profile contains various options that control how data in a chart is displayed. For example, these options control the display of labels, blank values, sub-charts, and others. Custom and profile-based queries
workpsaceId Number The Artifact identifier of the workspace to query. Common

Before you can use any type of field to group data in a Pivot query, the field must be enabled for grouping. Similarly, a field must be enabled for pivot before you can use it to pivot data. In addition, you can pivot data by using a Date field only if you also use a Date field to group data, and you can pivot data by month only if you also group data by year. For information about getting a list of workspace fields that you can use to group or pivot data, see Helper operations.

Note that you must have permission to view a field before you can use it in a Pivot query. Otherwise, an error occurs when you try to run the query because the Pivot Service Manager uses the permission settings of the active user account.

HTTP headers and status codes

The Pivot Manager service uses the same HTTP(S) headers and status codes as other services in the Relativity REST API. For details about required headers and fields, see HTTP headers. For details about HTTP status codes, see HTTP status codes.

Create a Pivot profile

To create a Pivot profile, send a request to this URL for the Pivot Manager service:

<host>/Relativity.Rest/API/Relativity.Services.Pivot.IPivotModule/Pivot%20Manager/CreateProfileAsync

The request includes the fields listed in the following sample JSON code. For more information about these fields, see Pivot profiles on the RelativityOne Documentation site.

{
  "workspaceId": 1015337,
  "profile": {
    "Name": "Create",
    "SortOn": "GrandTotal",
    "SortOrder": "Ascending",
    "PageSize": 10,
    "SwitchSeries": "false",
    "Toggles": {
      "ShowBlankValues": false,
      "ShowLegend": true
      "ShowSubChart": true

    },
    "ObjectType": {
      "Name": "Document"
    },
    "GroupByField": {
      "ArtifactID": 1035357
    },
    "PivotOnField": {
      "ArtifactID": 1035351
    },
    "ChartType": "Bar",
    "ChartOrientation": "Vertical"
  }
}

The response returns a JSON object with the fields set in the new Pivot profile.

Read a Pivot profile

To read and run a query based on a Pivot profile, send a request to the following Pivot Manager service URL:

<host>/relativity.rest/api/Relativity.Services.Pivot.IPivotModule/Pivot%20Manager/ExecutePivotProfileAsync

Ensure that the request includes required headers for the Relativity REST API and required fields for the Pivot Manager service. The required fields are: workspaceId, pivotProfileId, and objectSetQuery.

In the following example, a client reads and runs a query based on a Pivot profile. The profile is stored in a workspace that has the Artifact identifier value “1032131”. The profile has the Artifact identifier value “1081794”. The query isn’t limited to a subset of documents or objects in the workspace, as indicated by a Null value for the objectSetQuery field condition.

{
     workspaceId: 1032131, 
     pivotProfileId: 1081794,
     objectSetQuery: { Condition: " " }
}

To see the JSON response to the preceding request, see Sample JSON response. For insight into the Pivot profile settings that generated the response, see the next section, which demonstrates how to create a custom Pivot query and uses the same settings as the Pivot profile in the preceding example.

Update a Pivot profile

To update a Pivot profile, send a request to this URL for the Pivot Manager service:

<host>/Relativity.Rest/API/Relativity.Services.Pivot.IPivotModule/Pivot%20Manager/UpdateProfileAsync

The request includes the fields listed in the following sample JSON code. For more information about these fields, see Pivot profiles on the RelativityOne Documentation site.

{
  "workspaceId": 1015337,
  "profile": {
    "Name": "Update",
    "SortOn": "GrandTotal",
    "SortOrder": "Ascending",
    "PageSize": 10,
    "SwitchSeries": "false",
    "Toggles": {
      "ShowBlankValues": false,
      "ShowLegend": true
      "ShowSubChart": true
    },
    "ObjectType": {
      "Name": "Document"
    },
    "ID": 1040623,
    "GroupByField": {
      "ArtifactID": 1035357
    },
    "PivotOnField": {
      "ArtifactID": 1035351
    },
    "ChartType": "Bar",
    "ChartOrientation": "Vertical"
  }
}

The response returns a JSON object with the fields set in the updated Pivot profile.

Create a custom Pivot query

To create and run a custom Pivot query, send a request to the following Pivot Manager service URL:

http://localhost/relativity.rest/api/Relativity.Services.Pivot.IPivotModule/Pivot%20Manager/ExecuteAsync

Ensure that the request includes required headers for the Relativity REST API and required fields for the Pivot Manager service. Required fields are:

To determine which fields you want to use to group and pivot data, you can use Pivot Service Manager helper operations to get a list of workspace fields that are enabled for grouping and pivoting.

The following code example defines a custom query that primarily does the following:

  1. Queries all documents in a workspace.
  2. Groups data by the email address stored in a Fixed-Length Text field named “Email From”.
  3. Pivots data based on the values in a Yes/No field named “Designation”.

To optimize workspace performance and query results, the example also limits the number of results returned and specifies a timeout value for stopping the query.

{
     //Specify which workspace to query.
     workspaceId: 1032131,
     settings: {
          /*
          Set the Artifact Type identifier of the DTO to query. This example queries documents, which 
          have an ArtifactTypeID value of “10”.
          */
          ArtifactTypeID: 10, 
          
          //Group data by using the “Email From” field, which has a view field identifier value of “1000566”.
          GroupBy: { 
               ViewFieldID: 1000566	
          },
          
          //Pivot data by using the “Designation” field, which has a view field identifier value of “1000555”.
          PivotOn: {
               ViewFieldID: 1000555
          },
		
          //Limit the results to a specific number of columns and rows.
          MaximumNumberOfColumns: 50,
          MaximumNumberOfRows: 1200,

          //Run the query for no more than 1,020 seconds (17 minutes).
          Timeout: 1020,

          //Return only the data in query results; do not apply Pivot view settings to the results.
          RawDataOnly: false,

          //Query all documents in the workspace; do not limit the query to a subset of documents. 
          ObjectSetQuery: { Condition: " " },
     } 
}

Export a Pivot query

To export a Pivot query, send a request to this URL for the Pivot Manager service:

<host>/Relativity.Rest/API/Relativity.Services.Pivot.IPivotModule/Pivot%20Manager/ExecuteExportAsync

The request includes the fields listed in the following sample JSON code. For more information about these fields, see Pivot profiles on the RelativityOne Documentation site.

The response contains the Content Type, and Content field, which has been truncated in the following example. It also includes a Success field, which indicates the status of the export.

{
   "ContentType":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
   "Content":"UEsDBBQABggIAAAAIQC1VTAj6wAAAEwCAAALAAgCX3JlbHMvLnJlbHMgogQCKKAAAgAAAAAAAA...",
   "Success":true
}

Sample JSON response

The following JSON sample shows the response to the custom Pivot query and the profile-based query discussed in the preceding sections. The Results fields report the total number of documents (891) that are in the workspace and contain data in the Email From field. They also report how many of those documents are coded as responsive (True) and non-responsive (False).

Subsequent objects are grouped by the email address stored in the Email From field. The object fields report the applicable email address, the number of documents tagged as responsive (True) and non-responsive (False) for the address, and the total number of documents that have the address in the Email From field. The last four fields in the response provide information about the Pivot query overall—the query returned 277 objects, a Query object was not used, and the query ran successfully.

Helper operations

To help you determine which fields you can use to group and pivot data in a Pivot query, the Pivot Manager Service provides the following helper operations:

Note that the list of fields that is returned includes only those fields that you have permission to view. As is the case with Pivot queries, the helper operations use the permission settings of the active user account.

getGroupByFieldsForDocuments

To get a list of all the fields that you can use to group data in a workspace, send an HTTP(S) POST request to the following URL:

http://localhost/relativity.rest/api/Relativity.Services.Pivot.IPivotModule/Pivot%20Manager/GetFieldsForGroupByAsync

Required fields for the request are workspaceId and ArtifactTypeId. For example, the following request returns a list of fields that are in a workspace that has an Artifact identifier value of “1234567”, apply to the Document object, can be used to group data, and the active user has permission to view:

{
     workspaceId: 1234567,
     ArtifactTypeId: 10
};

The JSON response returns the Artifact identifier, view field identifier, and name of each field:

{
     "ArtifactID": 1055916,
     "ViewFieldID": 1001647,
     "Guids": [],
     "Name": "Date Sent"
},
{
     "ArtifactID": 1039789,
     "ViewFieldID": 1001039,
     "Guids": [],
     "Name": "Docs_Languages::Language"
},
{
     "ArtifactID": 1055919,
     "ViewFieldID": 1001650,
     "Guids": [],
     "Name": "Email From"
},
{
     "ArtifactID": 1055923,
     "ViewFieldID": 1001654,
     "Guids": [],
     "Name": "Extension"
}

When you create a custom query, you can use any of those identifiers to specify the field that you want to use to group data.

getPivotOnFieldsForDocuments

To get a list of all the fields that you can use to pivot data in a workspace, send an HTTP(S) POST request to the following URL:

http://localhost/relativity.rest/api/Relativity.Services.Pivot.IPivotModule/Pivot%20Manager/GetFieldsForPivotOnAsync

Required fields for the request are workspaceId and ArtifactTypeId. In the following example, the request returns a list of fields that are in a workspace that has an Artifact identifier value of “1234567”, apply to the Document object, can be used to pivot data, and the active user has permission to view:

{
     workspaceId: 1234567,
     ArtifactTypeId: 10
};

The JSON response returns the Artifact identifier, view field identifier, and name of each field:

{
     "ArtifactID": 1055916,
     "ViewFieldID": 1001647,
     "Guids": [],
     "Name": "Date Sent"
},
{
     "ArtifactID": 1039789,
     "ViewFieldID": 1001039,
     "Guids": [],
     "Name": "Docs_Languages::Language"
},
{
     "ArtifactID": 1055919,
     "ViewFieldID": 1001650,
     "Guids": [],
     "Name": "Email From"
},
{
     "ArtifactID": 1055923,
     "ViewFieldID": 1001654,
     "Guids": [],
     "Name": "Extension"
}

When you create a custom query, you can use any of those identifiers to specify the field that you want to use to pivot data.

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