Calculation formulas (expressions)
Overview
Auto-calculation expressions for a question can be retrieved using the GET request from this endpoint. These expressions show the formulas required when a calculation exists between two or more questions (e.g. Q3 = Q1 * Q2).
Pre-requisites: Valid subscription key and organization UUID for the respective Disclosure API environment.
Note – Data Sync: To ensure retrieval of accurate data, it is essential to refresh this request each time the questionnaire is republished. Your Account Manager will inform you if any such changes occur during the cycle.
GET request
Details how to send the request to the questionnaire/expressions endpoint and the response that is returned when a successful request is sent.
URLs
| Environment | URL |
|---|---|
| Sandbox | https://api.pre.cdpgreenstar.net/asp/response/questionnaire/expressions |
| Production | https://api.cdp.net/response/questionnaire/expressions |
Parameters
| Name | Location | Description |
|---|---|---|
subscription-key | header | For authorized user, the subscription key. |
organization-id | header | Enter the UUID for the organization's response. |
Body
NULL
Response
Top level: Expression (n)
Information regarding the auto-calculations included within the given questionnaire structure.
Note: The response from this endpoint is not controlled by Tag Matching. All expressions, for an entire questionnaire, are returned each time regardless of whether they are relevant to the provided disclosing organization.
Field table
| Field | Description | Data Type |
|---|---|---|
id | The expression's UUID. This is shared across all organizations. | string |
questionId | The ID for the question the expression belongs to. | string |
rowId | The ID for the row the expression belongs to. | string |
postfix | List of the values to be used in the calculation and the operator to be applied between them. Standard question: [[Q1 ID], [Q2 ID], Operand]Matrix question: [[Q1 Parent ID, Q1 Row ID, Q1 ID], [Q2 Parent ID, Q2 Row ID, Q2 ID], Operand]Note: Use JSON.parse to clean string. | string |
row | If the expression is within a matrix question, then additional information about the row and parent question is included. Note: Typically, expressions are only applied within matrix questions. | array |
leadingQuestionId | The parent question ID of the question the expression belongs to. | string |
Schema
{
"id": "string",
"questionId": "string",
"rowId": "string",
"postfix": "string",
"row": [{...}],
"leadingQuestionId": "string"
}
Second level: row (n+1)
Additional information about the row and matrix question that the expression belongs to, if applicable.
Field table
| Field | Description | Data Type |
|---|---|---|
id | The row ID. | string |
complexQuestionId | The ID of the question the row is part of. | string |
Schema
[{
...
"row": {
"id": "string",
"complexQuestionId": "string"
}
...
}]
JSON response example
[
{
"id": "5276e4b4-b392-4f01-9553-f93f2a730abf",
"questionId": "4412c72f-922f-4241-894f-4302862bc641",
"rowId": "00fcaf8e-530d-4ac7-924e-8cbe4a38d5cc",
"postfix": "[[\"1491b888-7468-4c3a-a4bb-d09bd3a714b7\",\"00fcaf8e-530d-4ac7-924e-8cbe4a38d5cc\",\"1f7f991c-48fa-4896-896c-db8a3e5c6c66\"],[\"1491b888-7468-4c3a-a4bb-d09bd3a714b7\",\"00fcaf8e-530d-4ac7-924e-8cbe4a38d5cc\",\"bde02880-4283-4ce7-a325-38a2c585fbb2\"],\"+\",[\"1491b888-7468-4c3a-a4bb-d09bd3a714b7\",\"00fcaf8e-530d-4ac7-924e-8cbe4a38d5cc\",\"83662716-0947-4f1b-9f6b-4f1d148b403b\"],\"+\",[\"1491b888-7468-4c3a-a4bb-d09bd3a714b7\",\"00fcaf8e-530d-4ac7-924e-8cbe4a38d5cc\",\"9a0ccd39-8595-4ad2-851d-9d53ebd9ebdf\"],\"+\"]",
"row": {
"id": "00fcaf8e-530d-4ac7-924e-8cbe4a38d5cc",
"complexQuestionId": "1491b888-7468-4c3a-a4bb-d09bd3a714b7"
},
"leadingQuestionId": "1491b888-7468-4c3a-a4bb-d09bd3a714b7"
}
]
Note: When three IDs are included within a single square bracket
[ ], it points to a single value within a matrix question. These IDs are "parentQuestionID", "rowID", and "childQuestionID" respectively.