How to find the tasks present in the project?

407 views Asked by At

In ServiceNow,

I am hving a project number - PRJ0012345. But how to find the task / userstory assciated with this project.

I had tried the following service

https://xyz.service-now.com/pm_project.do?WSDL

For data retreiving I used the following SOAP url https://xyz.service-now.com/pm_project.do?displayvalue=true&SOAP

Code:

           private static string url = "https://xyz.service-now.com/pm_project.do?displayvalue=true&SOAP";
           private static ServiceNowPMProjectService.getRecordsResponseGetRecordsResult[] recordResults;
           var proxy = new ServiceNow_pm_project
            {
                Url = url,
                Credentials = new NetworkCredential(userName, password)
            };

            var objRecord = new ServiceNowPMProjectService.getRecords
            {
                number = "PRJ0012156"
            };

            recordResults = proxy.getRecords(objRecord);

From recordResults, I am not able to figure out how to find the related tasks / userstories associated with this project.

Note: If any other service url is used also, can mention here. I will give a try to find out related userstories / tasks.

Above service url uses pm_project table. Similarly, If some another table name in that url is used also, please mention. Thanks.

1

There are 1 answers

0
Bryan On

In ServiceNow to retrieve the project tasks related to a project using ServiceNow's SOAP Web Services you will need to make a request (getRecords) against the project tasks table querying for project tasks whose parent is the project you are interested in (in your case PRJ0012345).

This is because in ServiceNow the project record (pm_project) does not reference project tasks (pm_project_task), so a project does not know what project tasks are associated with it, but rather each project task has an reference to the project it is related to via the'parent' field on the project task record.

For example PRJ0012345, where PRJTASK0010002 is a child, related to PRJ0012345 by it's parent field.

PRJ0012345
    PRJTASK0010002 (parent=PRJ0012345)
    PRJTASK0010003 (parent=PRJ0012345)
    PRJTASK0010004 (parent=PRJ0012345)
    PRJTASK0010005 (parent=PRJ0012345)

Here is a sample soap request message body that is making a request to the pm_project_task SOAP Web Service and passing a query so that the result set will only contain pm project tasks whose parent is PRJ0010001.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pm="http://www.service-now.com/pm_project_task">
   <soapenv:Header/>
   <soapenv:Body>
      <pm:getRecords>       
         <__encoded_query>parentSTARTSWITHPRJ0010001</__encoded_query>       
      </pm:getRecords>
   </soapenv:Body>
</soapenv:Envelope>

If I knew the sys_id (unique identifier of the parent project) I could alter my soap request message body to use that sys_id like so:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pm="http://www.service-now.com/pm_project_task">
   <soapenv:Header/>
   <soapenv:Body>
      <pm:getRecords>       
         <__encoded_query>parent=91668b5e0ff842003a2d47bce1050e61</__encoded_query>       
      </pm:getRecords>
   </soapenv:Body>
</soapenv:Envelope>

Per your example I would suggest you try modifying your code to use '__encoded_query' as shown below:

var objRecord = new ServiceNowPMProjectService.getRecords
            {
                __encoded_query = "parentSTARTSWITHPRJ0012345"
            };

Hope that helps!