How to fetch change task details associated with a change request ?

learner12
Kilo Contributor

Hi All,

I am trying to get the details of a change request usign the JSON service.

Url : https://<instance name>.service-now.com/change_request.do?XML&sysparm_query=number=CHG000abc&display...

In the response , I am not able to find any change task details. Kindly let me know how to get the change task details assiciated with a change request.

Thanks!

13 REPLIES 13

If you are starting with a change number and want to get a series of change tasks, you will need to do this with two queries.



The first gets the details of the change request (including the sys_id)



https://yourinstance.service-now.com/api/now/table/change_request?sysparm_query=number=CHGXXXXXXX&sy...



// Parse sys_id from response here



The second one looks for all the change_tasks where parent is the sys_id returned from the first query plus the date parameters you requested.


Hi - was there supposed to be a second query in your example above?



I wouldn't be starting with a Change number. I want to show a team all the Changes (including their child Tasks) that are planned this week for their CIs, or their Assignment Group, for example.



Again, I'd think we're not the only company that needs this kind of view. So there really should be a standard "1-query" method to do this in SN out of the box.


Hi AJ,


I want to show a team all the Changes (including their child Tasks) that are planned this week for their CIs, or their Assignment Group



Thank you for the clarification. Understanding the underlying requirement or use case is always helpful. When people come and ask a technical question (their thought on what the solution is) you can often end up with sub-optimal answers.



That being said, yes, you can get this in one query. Query the task table and use a sysparm_query to filter on just the change_request and change_task tables to get the records you want. I recommend experimenting with the REST API Explorer to refine your query.



Getting Started with REST - ServiceNow Wiki


REST API Explorer - ServiceNow Wiki


REST API  


RE: "from change number can we get the associated ctask numbers ?"



I assume by now you've found a query like the following?


https://{{instance-name}}.service-now.com/api/now/table/change_task?change_request=CHG0036876&sysparm_fields=number,sys_id