[]
        
(Showing Draft Content)

Manage Reports

This page discusses using Wyn restful API through GraphQL query language to work with reports.

Get information on a report

To obtain information on report properties and parameters the list of all the resources available to you, use the reportInfo as follows.


Request Example

query {
  reportInfo(reportId: "010a48f3-7e6c-485e-97bb-5df5dbd9fb8e") {
    name, displayType, sizeType, isFPL,
    parameters {
      name, prompt, dataType, selectAllValue,
      allowBlank, nullable, multiValue, multiline,
      hidden, usedInQuery, dependsOn, dateOnly,
      validValues {
        values { label, value }
      },
      defaultValue { values }
    }
  }
}

Response Example

"data": {
    "reportInfo": {
      "name": "param test",
      "displayType": "Page",
      "sizeType": "Default",
      "isFPL": false,
      "parameters": [
        {
          "name": "Parameter1",
          ...
          "validValues": {
            "values": [
              {
                "label": "Param1 label 1",
                "value": "param1value1"
              },
              {
                "label": "Param1 label 2",
                "value": "param1value2"
              },
              {
                "label": "Param1 label 3",
                "value": "param1value3"
              }
            ]
          },
          "defaultValue": {
            "values": [
              "param1value2"
            ]
          }
        }
    ...

The following table elaborates on key attributes available in the reportInfo object.

Attributes

Description

id

Gets the resource ID or document ID

name

name of the report

displayType

eg. Page

sizeType

eg. Default, FitToPage

isFPL

Returns boolean value, whether the report is a fixed page layout

parameters{}

Information on report parameters. The following attributes are available:

  • name - of the parameter

  • prompt - prompt of the parameter

  • dataType - the data type of the parameter

  • selectAllValue - value passed in Select All Value property in case of multivalued parameter

  • allowBlank - if allow blank is set

  • nullable - if a null value is allowed in the parameter

  • multiValue - if the parameter is multivalued

  • multiline - if multi line text is allowed

  • hidden - if the parameter is hidden

Get information on report parameters

To obtain available values for child parameters depending on selected parent parameter values, use the reportParameterValues in a query as follows.


Request Example

query {
  reportParameterValues(
    reportId: "5d6fa0cb92c4090094da243d",
    parameterRequest: {
      request: ["Parameter4"],
      values: [{
        key: "City",
        values: ["London"]
      }]
    }
  ) {
        parameters {
      key,
      value { validValues { label, value }, values } }
  }
}

Response Example

{
  "data": {
    "reportParameterValues": {
      "parameters": [
        {
          "key": "Parameter4",
          "value": {
            "validValues": [
              {
                "label": "Around the Horn",
                "value": "Around the Horn"
              },
              {
                "label": "B's Beverages",
                "value": "B's Beverages"
              }
            ],
            "values": [
              "Around the Horn"
            ]
          }
        }
      ]
    }
  },
  "errors": null
}

Export a report

To export a report using the provided export settings and report parameters, use the exportReport in mutation. If there are errors during export result streaming, check export errors after reading the result stream, using the resultUrl and the verificationUrl.


Request Example

mutation {
   exportReport(
     reportId: "c788aca9-d72e-4b2d-ab55-167e380b670f",
     exportExtension: "pdf",
     renderPayload: {
     settings: [{
     key: "IsPaginated",
     value: "false"
     }]
    })
  {
   resultUrl,
   verificationUrl
 }
}

Response Example

{
  "data": {
    "exportReport": {
      "resultUrl": "/api/workerJob/b9a39275-fc5a-43cd-9bfc-dd94622f1228",
      "verificationUrl": "/api/workerJob/b9a39275-fc5a-43cd-9bfc-dd94622f1228/verify"
    }
  },
  "errors": null
}

The following table elaborates on key attributes available in the exportReport object.

Attributes

Description

reportId

Report ID of the report you want to export

exportExtension

The rendering extension or export type. Acceptable values are: "pdf", "csv", "excel", "docx", "html", "image", and "json".

renderPayload{}

The information on report parameters.

Render a report

To render or view a report, use the render mutation. The mutation returns the job id when the report is rendered, which should be used to obtain the document Id or error message. See obtaining Job status in the next section.


Request Example

mutation {
  render(
    reportId: "5d6fa0cb92c4090094da243d",
    renderPayload: {
      parameters: [{
        key: "Parameter1", value: "param1value2"
      }, {
        key: "Parameter2", value: "param2value1"
      }, {
        key: "City", value: "London"
      }, {
        key: "Parameter4", value: "Around the Horn"
      }]
    }
  ) {
    jobId
  }
}

Response Example

{
  "data": {
    "render": {
      "jobId": "799529e3-0c59-48bc-a97c-8b82cd719efc"
    }
  },
  "errors": null
}

Job status

To obtain rendering job status - RUNNING, SUCCESS, or ERROR. If a job has been completed successfully, the documentId field is set to rendered document id, which can be used further for export using exportDocument mutation.


If the job fails, the error field contains an error message. Note that if a job is running, the server will wait for the job to finish for a period of time before answering the client, so there may be a delay on the server side.


Request Example

query {
  job(
    jobId: "799529e3-0c59-48bc-a97c-8b82cd719efc"
  ) {
    status, documentId, error
  }
}

Response Example

{
  "data": {
    "job": {
      "status": "SUCCESS",
      "documentId": "77260328-9ae0-4f41-ad4f-cfb457ab04b7",
      "error": null
    }
  },
  "errors": null
}

Export a document

To export a rendered document using the provided export settings use the exportDocument mutation.


Note that the report parameters are closely connected to the rendered document and cannot be changed without calling /render mutation as explained in the Render report section.


Returns export result URL and result verification URL


Request Example

mutation {
  exportDocument(
    documentId: "77260328-9ae0-4f41-ad4f-cfb457ab04b7",
    exportExtension: "pdf",
    renderPayload: {}
  ) {
    resultUrl, verificationUrl
  }
}

Response Example

{
  "data": {
    "exportDocument": {
      "resultUrl": "/api/workerJob/a4480e07-9a84-4aa6-adc2-08c498abb86c",
      "verificationUrl": "/api/workerJob/a4480e07-9a84-4aa6-adc2-08c498abb86c/verify"
    }
  },
  "errors": null
}

Close Document

To remove the rendered document from the server, use the following mutation.


Request Example

mutation {
  closeDocument(
    documentId: "26f7f1ad-0536-4a8c-8884-bd43d923b308")
}

Response Example

{
  "data": {
    "closeDocument": true
  },
  "errors": null
}
mutation {
  closeDocument(
    documentId: "26f7f1ad-0536-4a8c-8884-bd43d923b308")
}

Response Example

{
  "data": {
    "closeDocument": true
  },
  "errors": null
}