ServiceNowAddComment

Use this script to add a comment or work note to a ServiceNow ticket. To be run within the incident.

python · ServiceNow

Details

IDServiceNowAddComment
Languagepython
From Version6.8.0
Docker Imagedemisto/python3:3.12.13.10116658
Tagsservicenow servicenow v2
def test_update_comment_or_worknote(mocker):
    # test update_comment_or_worknote function
    import ServiceNowAddComment
    from ServiceNowAddComment import demisto, update_comment_or_worknote

    mocker.patch.object(
        demisto,
        "executeCommand",
        return_value=[
            {
                "Contents": {
                    "result": {
                        "sys_id": "1",
                        "sys_updated_on": "2",
                        "sys_updated_by": "3",
                        "number": "4",
                        "sys_class_name": "5",
                        "sys_created_by": "6",
                        "sys_created_on": "7",
                    }
                }
            }
        ],
    )
    mocker.patch.object(ServiceNowAddComment, "isError", return_value=False)
    update_comment_or_worknote({"ticket_id": "1", "note": "test"})
    assert demisto.executeCommand.call_count == 1
    assert demisto.executeCommand.call_args[0][0] == "servicenow-update-ticket"
    assert demisto.executeCommand.call_args[0][1]["id"] == "1"
    assert demisto.executeCommand.call_args[0][1]["work_notes"] == "test"