How can we send "work notes" in the API along with number, state, short description?

Shantharao
Kilo Sage

Hi All,
I want to send "work notes" in the API along with number, state, short description?
Is it possible by using REST API explorer or do we need to create a custom API

Thanks in advance your response

4 REPLIES 4

SANDEEP DUTTA
Tera Patron
Tera Patron

Hi @Shantharao ,

By default the REST Table API will not return content of Work Notes[work_note] and Additional Comments[comments] when retrieving data for records that use these fields (usually Task-derived records like Incident, Change Request and so on). 

There are two ways to retrieve Work Notes[work_note] and Additional Comments[comments] through the REST Table API:

  1. Add sysparm_display_value=true parameter in the request, this returns the full text of Work Notes and Additional Comments.
  2. Or alternatively export the Journal Field[sys_journal_field] records where Element and Element ID match the record (incident, change request etc) that you're exporting.

 

Or, you can build a Rest Message and trigger it with the help of an business rule : https://www.servicenow.com/community/developer-articles/rest-message-send-work-notes-and-additional-...

 

 

Thanks,
Sandeep Dutta

Please mark the answer correct & Helpful, if i could help you.

Hi @SANDEEP DUTTA ,
By using sysparm_display_value=true parameter, 
I can be able to send the work notes but it shows date stamp and person names who updated entry, but the 3rd party application team wants only the latest entry without timestamp 

Can you please advice me?

Thanks

Ankur Bawiskar
Tera Patron
Tera Patron

@Shantharao 

what's your actual business requirement?

are you consuming some API? how is that consumed?

what script did you write so far and what's not working?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

yesubabu Jonnal
Tera Contributor

Hi 

If you have an end pint url , add the condition in BR when to send & follow the below code.

 

var endpoint = gs.getProperty('Keep your API');    
    var Number = String(current.number);
    var Incidentstate = String(current.state);
    var shortdescription = String(current.short_description);
    var request = new sn_ws.RESTMessageV2();
    var requestBody = {
        "number": Number ,
        "state": Incidentstate ,
        "Incident shortdescription": shortdescription,
    };
    request.setRequestBody(JSON.stringify(requestBody));
    request.setEndpoint(endpoint);
    request.setHttpMethod('POST');
    request.setRequestHeader("Accept", "application/json");
    request.setRequestHeader("Content-Type", "application/json");
    var response = request.execute();
    var responseBody = response.getBody();
    var httpStatus = response.getStatusCode();
    var parsedData = JSON.parse(responseBody);