Why would my additional comments Not be using the api?

stevecrocker
Kilo Expert

I'm doing a business rule that is using the REST Put method (which is working perfectly). I'm using the script inside of a business rule and when I put something else into the field (different variable) it works, when I try current.comments it's blank and doesn't look like it even fires off the Rest method.   I've looked at the Outbound HTTP Request and it's showing 200.

Does anyone know how to fix this?   It appears that the comment is not getting put into the Put Request

Here is my BR script:   The red line is the one not picking up the additional comments from the ticket (which on checking the name is comments).

(function executeRule(current, previous /*null when async*/) {

try {

var r = new sn_ws.RESTMessageV2('Zendesk', 'ZD-Put');

r.setStringParameter('comment', current.comments);

r.setStringParameterNoEscape('Snow_sys_id', current.sys_id);

r.setStringParameterNoEscape('id', current.u_correlation_id);

var response = r.execute();

var responseBody = response.getBody();

var httpStatus = response.getStatusCode();

}

catch(ex) {

var message = ex.getMessage();

}

})(current, previous);

*****Here is the PUT payload

{

        "ticket":{

                      "id":"${id}",

                      "comment":"${comment}",

                        "custom_fields":

[{"id": "114102725251", "value":"${Snow_sys_id}"}]

                                  }

}

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Stephen,



The comments is a journal field so current.comments won't give you the latest comment added.


use


current.comments.getJournalEntry(1)


you need to do string manipulation to only get the comments.


Getting the first record of a Journal Entry



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Stephen,



The comments is a journal field so current.comments won't give you the latest comment added.


use


current.comments.getJournalEntry(1)


you need to do string manipulation to only get the comments.


Getting the first record of a Journal Entry



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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