Skip to content

Commit 86f1e4c

Browse files
daryakovalroysagi
andauthored
Add sc_req_item and incident ticket types to incident mirroring. (demisto#11396)
* added incident mirroring * update rn * solvad conflicts * Update 2_1_14.md Co-authored-by: roysagi <[email protected]>
1 parent a77432f commit 86f1e4c

5 files changed

Lines changed: 25 additions & 8 deletions

File tree

Packs/ServiceNow/Integrations/ServiceNowv2/ServiceNowv2.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2171,8 +2171,13 @@ def update_remote_system_command(client: Client, args: Dict[str, Any], params: D
21712171
if parsed_args.incident_changed:
21722172
demisto.debug(f'Incident changed: {parsed_args.incident_changed}')
21732173
# Closing sc_type ticket. This ticket type can be closed only when changing the ticket state.
2174-
if ticket_type == 'sc_task' and parsed_args.inc_status == IncidentStatus.DONE and params.get('close_ticket'):
2174+
if (ticket_type == 'sc_task' or ticket_type == 'sc_req_item')\
2175+
and parsed_args.inc_status == IncidentStatus.DONE and params.get('close_ticket'):
21752176
parsed_args.data['state'] = '3'
2177+
# Closing incident ticket.
2178+
if ticket_type == 'incident' and parsed_args.inc_status == IncidentStatus.DONE and params.get('close_ticket'):
2179+
parsed_args.data['state'] = '7'
2180+
21762181
fields = get_ticket_fields(parsed_args.data, ticket_type=ticket_type)
21772182
if not params.get('close_ticket'):
21782183
fields = {key: val for key, val in fields.items() if key != 'closed_at' and key != 'resolved_at'}

Packs/ServiceNow/Integrations/ServiceNowv2/ServiceNowv2.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,7 @@ script:
13761376
- change_request
13771377
- sc_request
13781378
- sc_task
1379+
- sc_req_item
13791380
required: false
13801381
secret: false
13811382
- default: false

Packs/ServiceNow/Integrations/ServiceNowv2/ServiceNowv2_test.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -783,9 +783,10 @@ def test_upload_entries_update_remote_system_command(mocker):
783783

784784

785785
def ticket_fields(*args, **kwargs):
786+
state = '7' if kwargs.get('ticket_type') == 'incident' else '3'
786787
assert {'close_notes': 'This is closed', 'closed_at': '2020-10-29T13:19:07.345995+02:00', 'impact': '3',
787788
'priority': '4', 'resolved_at': '2020-10-29T13:19:07.345995+02:00', 'severity': '1 - Low',
788-
'short_description': 'Post parcel', 'sla_due': '0001-01-01T00:00:00Z', 'urgency': '3', 'state': '3',
789+
'short_description': 'Post parcel', 'sla_due': '0001-01-01T00:00:00Z', 'urgency': '3', 'state': state,
789790
'work_start': '0001-01-01T00:00:00Z'} == args[0]
790791

791792
return {'close_notes': 'This is closed', 'closed_at': '2020-10-29T13:19:07.345995+02:00', 'impact': '3',
@@ -795,27 +796,33 @@ def ticket_fields(*args, **kwargs):
795796

796797

797798
def update_ticket(*args):
799+
state = '7' if 'incident' in args else '3'
798800
return {'short_description': 'Post parcel', 'close_notes': 'This is closed',
799801
'closed_at': '2020-10-29T13:19:07.345995+02:00', 'impact': '3', 'priority': '4',
800802
'resolved_at': '2020-10-29T13:19:07.345995+02:00', 'severity': '1 - High - Low',
801-
'sla_due': '0001-01-01T00:00:00Z', 'state': '3', 'urgency': '3', 'work_start': '0001-01-01T00:00:00Z'}
803+
'sla_due': '0001-01-01T00:00:00Z', 'state': state, 'urgency': '3', 'work_start': '0001-01-01T00:00:00Z'}
802804

803805

804-
def test_update_remote_data_sc_task(mocker):
806+
@pytest.mark.parametrize('ticket_type', ['sc_task', 'sc_req_item', 'incident'])
807+
def test_update_remote_data_sc_task_sc_req_item(mocker, ticket_type):
805808
"""
806809
Given:
807810
- ServiceNow client
808811
- ServiceNow ticket of type sc_task
812+
- ServiceNow ticket of type sc_req_item
813+
- ServiceNow ticket of type incident
814+
809815
When
810816
- running update_remote_system_command.
811817
Then
812-
- The state is changed to 3 (closed) after update.
818+
- The state is changed to 3 (closed) after update for sc_task and sc_req_item.
819+
- The state is changed to 7 (closed) after update for incident.
813820
"""
814821
client = Client(server_url='https://server_url.com/', sc_server_url='sc_server_url', username='username',
815822
password='password', verify=False, fetch_time='fetch_time',
816823
sysparm_query='sysparm_query', sysparm_limit=10, timestamp_field='opened_at',
817-
ticket_type='sc_task', get_attachments=False, incident_name='description')
818-
params = {'ticket_type': 'sc_task', 'close_ticket': True}
824+
ticket_type=ticket_type, get_attachments=False, incident_name='description')
825+
params = {'ticket_type': ticket_type, 'close_ticket': True}
819826
args = {'remoteId': '1234', 'data': TICKET_FIELDS, 'entries': [], 'incidentChanged': True, 'delta': {},
820827
'status': 2}
821828
mocker.patch('ServiceNowv2.get_ticket_fields', side_effect=ticket_fields)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
#### Integrations
3+
##### ServiceNow v2
4+
- Added support for closing ticket of sc_req_item type via the outgoing mirror feature.

Packs/ServiceNow/pack_metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "ServiceNow",
33
"description": "Use The ServiceNow IT Service Management (ITSM) solution to modernize the way you manage and deliver services to your users.",
44
"support": "xsoar",
5-
"currentVersion": "2.1.13",
5+
"currentVersion": "2.1.14",
66
"author": "Cortex XSOAR",
77
"url": "https://www.paloaltonetworks.com/cortex",
88
"email": "",

0 commit comments

Comments
 (0)