/workorder/pcr/answer
This action sets the answer for one or more questions in a PCR form associated with a work order.
Request
| Field | Description | Required |
|---|---|---|
report_id | Unique identifier for the work order | Yes |
pcr_form_id | Unique identifier for the PCR form | Yes |
questions | Answers to PCR form questions | Yes |
questions must be an array of PCR question objects. Each PCR
question object must contain two fields — pcr_question_id and
answer.
The pcr_question_id uniquely identifies a question in the PCR form;
use the /workorder/pcr/get action to find the
pcr_question_id for a PCR question.
The answer field should specify the answer for the PCR question. The
answer’s type and value depends on the PCR question type. Use the
table below to figure out the answer’s type and value.
| PCR question type | Answer type | Answer value | Example |
|---|---|---|---|
| textbox | string | Any valid UTF-8 string value | "Briar Mount" |
| textarea | string | Any valid UTF-8 string value | "Lorem ipsum something" |
| numeric | number | Any valid number | 88.82 |
| dropdown | number | Must be $.questions[i].items[j].value from the PCR form object | 7517 |
| radio | number | Must be $.questions[i].items[j].value from the PCR form object | 8381 |
| checkbox | array | Each answer value in the array must be $.questions[i].items[j].value from the PCR form object | [7518, 7519, 7520] |
| date | string | Must be a date string in YYYY/MM/DD format | "2021/03/18" |
Example:
{
"report_id": 18851,
"pcr_form_id": 28,
"questions": [{
"pcr_question_id": 3801,
"answer": 7517
}, {
"pcr_question_id": 3802,
"answer": [7518, 7519, 7520]
}, {
"pcr_question_id": 3807,
"answer": 7535
}, {
"pcr_question_id": 3804,
"answer": "Briar Mount"
}, {
"pcr_question_id": 3870,
"answer": "Lorem ipsum something"
}, {
"pcr_question_id": 3819,
"answer": "2021/03/18"
}]
}
curl -H 'Content-Type: application/json' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-d '{"report_id":18851,"pcr_form_id":28,"questions":[{"pcr_question_id":3801,"answer":7517},{"pcr_question_id":3802,"answer":[7518,7519,7520]},{"pcr_question_id":3807,"answer":7535},{"pcr_question_id":3804,"answer":"Briar Mount"},{"pcr_question_id":3870,"answer":"Lorem ipsum something"},{"pcr_question_id":3819,"answer":"2021/03/18"}]}' \
https://ppw.web/svc/workorder/pcr/answer
Response
| Field | Description | Type |
|---|---|---|
results | Array of PCR question result objects | array |
Example successful response:
{
"results": [{
"id": 0,
"pcr_question_id": 3801,
"saved": false,
"msg": "Answer did not change; not saving"
}, {
"id": 1,
"pcr_question_id": 3802,
"saved": true,
"msg": "Answer saved"
}, {
"id": 2,
"pcr_question_id": 3807,
"saved": true,
"msg": "Answer saved"
}, {
"id": 3,
"pcr_question_id": 3804,
"saved": true,
"msg": "Answer saved"
}, {
"id": 4,
"pcr_question_id": 3870,
"saved": false,
"msg": "Answer did not change; not saving"
}, {
"id": 5,
"pcr_question_id": 3819,
"saved": true,
"msg": "Answer saved"
}]
}
Errors
| Error Type | Description | Status Code |
|---|---|---|
access_denied | Access token is invalid or expired | 401 |
scope_invalid | Client app does not have the required OAuth scope | 403 |
wo_invalid | Work order invalid | 400 |
pcr_form_id_invalid | PCR Form Id invalid | 400 |
questions_invalid | Questions is invalid | 400 |
questions_empty | Questions is empty | 400 |
pcr_not_attached | PCR form not attached to the work order | 400 |