0

How can we get the servicenow survey questions and responses using API?

I need to get all the responses for a survey I created including the question, answer and the ticket number.

I tried to get the responses from asmt_metric_result table, got the string value only. How can I get the question and ticket number as well?

Bemgi
  • 1
  • 1

1 Answers1

0

I was also trying to fetch the same details and finally understood how they are linked. It goes like:

  1. The asmt_metric_result table API response contains the user reponse (answer) for the given instance in string_value. It also has another key called instance_question which links to the question table.

    Ex:

"instance_question": {
"link": "https://servicenow.instance/api/now/table/asmt_assessment_instance_question/abcd",
"value": "abcd"
            }

Here the value refers to the sys_id

  1. Now, when you query the asmt_assessment_instance_question table, it will give you other links. Ex: https://servicenow.instance/api/now/table/asmt_assessment_instance_question?sys_id=abc

    This will return a response with a list of other keys.

    Here you have to refer the metric key which will link to another table called asmt_metric.

    Ex:

"metric": {
                "link": "https://servicenow.instance/api/now/table/asmt_metric/def",
"value": "def"
            }
  1. Now, you have to refer the asmt_metric table and it will return a response which has a key called question which will have the actual question. Ex:
"depends_on": "",
        "question": "I have reviewed the user list for terminated users.",
        "max": "1",

And, to get your Assessment instance number you can either refer the instance key returned in asmt_metric_result or asmt_assessment_instance_question responses.

You can also refer the source_id key in asmt_assessment_instance_question response as well.

Rohit Gupta
  • 4,022
  • 20
  • 31
  • 41
Karthik_S
  • 1
  • 2