Inserting comments and work notes into sys_journal_field

jmurtha
Kilo Contributor

How can I insert a work note into activity history for a given incident?

The way I am attempting to do it is via direct web service insert, which appears to be working because I get back a response with the sys_id of the new row created in sys_journal_field, but the work note does not show up when displaying the incident. Direct web services have worked so well for me in the past. What am I missing, doing wrong or don't understand?



<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sys="http://www.service-now.com/sys_journal_field">
<soapenv:Header/>
<soapenv:Body>
<sys:insert>
<!--Optional:-->
<sys:element>work_notes</sys:element>
<!--Optional:-->
<sys:element_id>abaa265cb881f400aee325aae407baed</sys:element_id>
<!--Optional:-->
<sys:name>task</sys:name>
<!--Optional:-->
<sys:value>And so my fellow Americans...</sys:value>
</sys:insert>
</soapenv:Body>
</soapenv:Envelope>

7 REPLIES 7

ShaneBrazeal
Tera Contributor

The activity log pulls from the sys_audit table.


jmurtha
Kilo Contributor

The suggestion to insert into the sys_audit table did not work.


jmurtha
Kilo Contributor

I am puzzled by the sys_journal_field table. I want to add work notes and comments to an incident using the direct web service insert API. I believe I am successfully calling the web service but the comment or work note does not show up in the incident in default view. However, switching to the soap response view, the comment and/or work note does appear. Clearly I am missing something, what is it?

The code segments below are ones I have copied from soapUI 4.0.1, I created a project with the http://[serviceNow instance]/sys_journal_field.do?wsdl.



<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sys="http://www.service-now.com/sys_journal_field">
<soapenv:Header/>
<soapenv:Body>
<sys:getRecords>
<sys:element_id>4c812350b8c1f400aee325aae407bad9</sys:element_id>
</sys:getRecords>
</soapenv:Body>
</soapenv:Envelope>




<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<getRecordsResponse xmlns="http://www.service-now.com/sys_journal_field">
<getRecordsResult>
<element>work_notes</element>
<element_id>4c812350b8c1f400aee325aae407bad9</element_id>
<name>task</name>
<sys_created_by>ahtrum</sys_created_by>
<sys_created_on>2012-10-09 16:42:41</sys_created_on>
<sys_id>48826350b8c1f400aee325aae407baa5</sys_id>
<value>Sys_id is 4c812350b8c1f400aee325aae407bad9</value>
</getRecordsResult>
</getRecordsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


The insert request default asks for element, element_id, name and value.


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sys="http://www.service-now.com/sys_journal_field">
<soapenv:Header/>
<soapenv:Body>
<sys:insert>
<!--Optional:-->
<sys:element>?</sys:element>
<!--Optional:-->
<sys:element_id>?</sys:element_id>
<!--Optional:-->
<sys:name>?</sys:name>
<!--Optional:-->
<sys:value>?</sys:value>
</sys:insert>
</soapenv:Body>
</soapenv:Envelope>


From the getRecordsResult above it appears that element is 'work_notes', the element_id corresponds with incident sys_id, 'task' appears to be the name and value is the work note text. So an example of an insert request would be as follows


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sys="http://www.service-now.com/sys_journal_field">
<soapenv:Header/>
<soapenv:Body>
<sys:insert>
<!--Optional:-->
<sys:element>work_notes</sys:element>
<!--Optional:-->
<sys:element_id>4c812350b8c1f400aee325aae407bad9</sys:element_id>
<!--Optional:-->
<sys:name>task</sys:name>
<!--Optional:-->
<sys:value>Work note text goes here...</sys:value>
</sys:insert>
</soapenv:Body>
</soapenv:Envelope>


john_andersen
Tera Guru

When going at this with Direct Web Services, I use the "update" function on the incident table.

The following SOAP Envelope is the the "update" function on my own "incident" table:



<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inc="http://www.service-now.com/incident">
<soapenv:Header/>
<soapenv:Body>
<inc:update>
<inc:sys_id>1b7c8faa7b6c7400e2ab314e7b4d4d88</inc:sys_id>
<inc:work_notes>note from John for the first time</inc:work_notes>
</inc:update>
</soapenv:Body>
</soapenv:Envelope>


In this envelope, the sys_id element is the sys_id to the incident record that I will be updating with a new work_note. The work_note element contains the text I will be inserting.

When I POST this to my instance, I get the following response:



<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<updateResponse xmlns="http://www.service-now.com/incident">
<sys_id>1b7c8faa7b6c7400e2ab314e7b4d4d88</sys_id>
</updateResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


This states that the update was successful.

I view my incident and the worknote is listed in the journal field:

find_real_file.png